Describe the bug
wamrc --enable-gc ... successfully compiles a valid Wasm GC module containing a global initializer that constructs a nested GC array using array.new_fixed, but LeakSanitizer reports leaked allocations from load_init_expr while loading the global section. The leak appears to be in loader-side handling of GC global initializer expressions.
Version
Version: 2.4.3
Commit: 4b306f0
To Reproduce
Steps to reproduce the behavior:
- Convert PoC to wasm:
(module
(type $bytes (array i8))
(type $arrs (array (ref eq)))
(global (ref $arrs)
i32.const 0
array.new_fixed $bytes 1
array.new_fixed $arrs 1
)
)
- Compile:
wamrc --bounds-checks=1 --enable-gc -o poc.aot poc.wasm
Expected behavior
No memory leak should occur.
Actual Result
==3203399==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x5555558f3797 in malloc (wasm-micro-runtime/wamr-compiler/build/wamrc-2.4.3+0x39f797)
#1 0x555555a82cc0 in loader_malloc wasm-micro-runtime/core/iwasm/interpreter/wasm_loader.c:345
#2 0x555555a82cc0 in load_init_expr wasm-micro-runtime/core/iwasm/interpreter/wasm_loader.c:1367
#3 0x555555aa2630 in load_global_section wasm-micro-runtime/core/iwasm/interpreter/wasm_loader.c:4355
#4 0x555555aa2630 in load_from_sections wasm-micro-runtime/core/iwasm/interpreter/wasm_loader.c:6401
#5 0x555555aaa8e8 in load wasm-micro-runtime/core/iwasm/interpreter/wasm_loader.c:7111
#6 0x555555aaa8e8 in wasm_loader_load wasm-micro-runtime/core/iwasm/interpreter/wasm_loader.c:7288
#7 0x555555a694fb in wasm_runtime_load_ex wasm-micro-runtime/core/iwasm/common/wasm_runtime_common.c:1515
#8 0x555555a694fb in wasm_runtime_load_ex wasm-micro-runtime/core/iwasm/common/wasm_runtime_common.c:1476
#9 0x555555a696b5 in wasm_runtime_load wasm-micro-runtime/core/iwasm/common/wasm_runtime_common.c:1568
#10 0x5555557a88c0 in main wasm-micro-runtime/wamr-compiler/main.c:840
#11 0x7ffff7629d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
SUMMARY: AddressSanitizer: 24 byte(s) leaked in 1 allocation(s).
Desktop:
- Arch [x86_64]
- OS [Linux]
- Version [Ubuntu 22.04]
Describe the bug
wamrc --enable-gc ...successfully compiles a valid Wasm GC module containing a global initializer that constructs a nested GC array usingarray.new_fixed, but LeakSanitizer reports leaked allocations fromload_init_exprwhile loading the global section. The leak appears to be in loader-side handling of GC global initializer expressions.Version
Version: 2.4.3
Commit: 4b306f0
To Reproduce
Steps to reproduce the behavior:
wamrc --bounds-checks=1 --enable-gc -o poc.aot poc.wasmExpected behavior
No memory leak should occur.
Actual Result
Desktop: