-
Notifications
You must be signed in to change notification settings - Fork 749
Enable memory leak check #1429
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
Enable memory leak check #1429
Conversation
Merge bytecodealliance:main into wenyongh:enable_mem_leak_check
| && (hmu_t *)((char *)cur + hmu_get_size(cur)) != end) { | ||
| os_printf("Memory leak detected:\n"); | ||
| gci_dump(heap); | ||
| #if WASM_ENABLE_SPEC_TEST != 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a config BH_EXIT_ON_GC_VERIFY_ERROR and exit(-1) here when it is enabled? This will be more friendly to instrumentation test framework
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will the return value -1 be gotten by the runtime embedder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will the return value -1 be gotten by the runtime embedder?
the -1 will be the exit code of the process and will be gotten by another process (instrument daemon server)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the exit(-1) in wasm_runtime_memory_destroy(), wasm_memory.c, for global heap only. As wasm app heap also uses ems gc, if it has memory leak, it will exit firstly, the global heap memory leak check will be ignored.
product-mini/platforms/posix/main.c
Outdated
| #if WASM_ENABLE_GLOBAL_HEAP_POOL != 0 | ||
| #ifdef __NuttX__ | ||
| static char global_heap_buf[WASM_GLOBAL_HEAP_SIZE * BH_KB] = { 0 }; | ||
| #elif WASM_ENABLE_SPEC_TEST != 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about merge these three definitions into one and define a platform dependent size (WASM_GLOBAL_HEAP_SIZE) for it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I defined the WASM_GLOBAL_HEAP_SIZE with unit bytes but not KB, is it OK for Nuttx?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to change
| CFLAGS += -DWASM_GLOBAL_HEAP_SIZE=$(CONFIG_INTERPRETERS_WAMR_GLOBAL_HEAP_POOL_SIZE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to change, like this?
CFLAGS += -DWASM_GLOBAL_HEAP_SIZE="$(CONFIG_INTERPRETERS_WAMR_GLOBAL_HEAP_POOL_SIZE) * 1024" There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it works.
Merge bytecodealliance:main into wenyongh:enable_mem_leak_check
Report the memory leak info when building iwasm with `cmake .. -DWAMR_BUILD_GC_VERIFY=1`
Report the memory leak info when building iwasm with
cmake .. -DWAMR_BUILD_GC_VERIFY=1.