-
Notifications
You must be signed in to change notification settings - Fork 749
Fix a bug that read a null pointer in jit_cc_destroy #1401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Use pointer comparison instead of struct memory comparison. When using call_indirect, type comparison is required. I optimized the speed of type comparison, and changed type structure memory comparison to pointer comparison.
whitch stores the number of type references
in wasm_interp_fast.c and wasm_interp_classic.c
when "globals" initialization fails, the memory allocated is not released, resulting in memory leakage
…der.c." This reverts commit cf45ba4.
after initialize a compilation context for fast jit failed.
|
IIUC, |
We use "Instrument Test" to test abnormal cases. |
|
@lum1n0us This issue is found by instrumentation test (it is a destructive test to cover abnormal cases). |
|
I know what you mean. JitCompContext *
jit_cc_init(JitCompContext *cc, unsigned htab_size)
{
JitBasicBlock *entry_block, *exit_block;
unsigned i, num;
memset(cc, 0, sizeof(*cc));
cc->_reference_count = 1;
jit_annl_enable_basic_block(cc);
/* Create entry and exit blocks. They must be the first two
blocks respectively. */
if (!(entry_block = jit_cc_new_basic_block(cc, 0))
|| !(exit_block = jit_cc_new_basic_block(cc, 0)))
goto fail;
/*ignored codes for convenience*/
cc->entry_label = jit_basic_block_label(entry_block);
cc->exit_label = jit_basic_block_label(exit_block);
/*ignored codes for convenience*/
fail:
jit_cc_destroy(cc);
return NULL;
}And when exec JitBasicBlock *
jit_cc_new_basic_block(JitCompContext *cc, int n)
{
JitReg label = jit_cc_new_label(cc);
JitBasicBlock *block = NULL;
if (label && (block = jit_basic_block_new(label, n)))
/* Void 0 register indicates error in creation. */
*(jit_annl_basic_block(cc, label)) = block;
else
jit_set_last_error(cc, "create basic block failed");
return block;
} |
…ytecodealliance#1401) The entry and exit basic blocks might be destroyed before they are created. Found by instrument test. Add checks to fix the issue.
Try to fix bug that it read a null pointer after initialize a compilation context for fast jit failed.
When memory_allocator_alloc return NULL, jit_cc_init will call jit_cc_destroy and we try to free the memory of cc.
But we ingored to do some check for cc->entry_label that may be 0 (This represents an initialization failure.), which causes the program to read a null pointer.
PS: This PR is for internal issues #403