From 1dcc59f234663b63b8a01d79621a76a3940c5839 Mon Sep 17 00:00:00 2001 From: Qiang <56512053+FromLiQg@users.noreply.github.com> Date: Wed, 24 Aug 2022 17:56:38 +0800 Subject: [PATCH] Fix fast jit destroy entry/exit basic block issue in jit_cc_destroy (#1401) The entry and exit basic blocks might be destroyed before they are created. Found by instrument test. Add checks to fix the issue. --- core/iwasm/fast-jit/jit_ir.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/iwasm/fast-jit/jit_ir.c b/core/iwasm/fast-jit/jit_ir.c index 2f78bb16..31315273 100644 --- a/core/iwasm/fast-jit/jit_ir.c +++ b/core/iwasm/fast-jit/jit_ir.c @@ -474,8 +474,10 @@ jit_cc_destroy(JitCompContext *cc) } /* Release entry and exit blocks. */ - jit_basic_block_delete(jit_cc_entry_basic_block(cc)); - jit_basic_block_delete(jit_cc_exit_basic_block(cc)); + if (0 != cc->entry_label) + jit_basic_block_delete(jit_cc_entry_basic_block(cc)); + if (0 != cc->exit_label) + jit_basic_block_delete(jit_cc_exit_basic_block(cc)); /* clang-format off */ /* Release blocks and instructions. */