Skip to content

Commit 7f94d18

Browse files
authored
dwarf_extractor.cpp: Fix buffer overruns (#3541)
Probably it's better to skip the optimized out parameters. (that is, parameters w/o locations) However, I'm not sure how/if it can be done with the lldb api. For now, just disable parameter processing to avoid crashes.
1 parent 3746534 commit 7f94d18

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

core/iwasm/compilation/debug/dwarf_extractor.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,20 @@ lldb_function_to_function_dbi(const AOTCompContext *comp_ctx,
418418
LLVMDIBuilderInsertDbgValueAtEnd(DIB, Param, ParamVar, ParamExpression,
419419
ParamLocation, block_curr);
420420

421-
if (!cplusplus) {
421+
if (num_function_args != func_ctx->aot_func->func_type->param_count) {
422+
// for C, this happens when the compiler optimized out some of
423+
// function parameters.
424+
//
425+
// for C++, this mismatch is normal because of the "this" pointer.
426+
if (!cplusplus) {
427+
LOG_WARNING("function args number mismatch! num_function_args: %d, "
428+
"wasm func params: %d, func: %s",
429+
num_function_args,
430+
func_ctx->aot_func->func_type->param_count,
431+
function_name);
432+
}
433+
}
434+
else if (!cplusplus) {
422435
auto variable_list = function.GetBlock().GetVariables(
423436
extractor->target, true, false, false);
424437
if (num_function_args != variable_list.GetSize()) {

0 commit comments

Comments
 (0)