-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
RuntimeError: memory access out of bounds inside posix_memalign, is there any way to have a libc with debug symbols? #13131
Comments
I have a PR open to add debug symbols to all system libraries: #13078 |
@sbc100 thanks:) Is there anything else I can do to dig deeper? I am quite new to WebAssembly but quite good with C++ and have learned a lot during the last two days starting from 0 :D My biggest issue here is that I really can't map the instructions I see with the code in emmalloc.cpp, so I can't locate the faulty region (and I assume this version of runtime I am getting is also heavily optimized). |
Is there some reason you are building with Normally an error like this that shows up in the allocator is a sign or memory corruptions somewhere else, since bugs in the allocators are fairly unlikely. You could try building with |
That part was from the original code, but I can try changing that. And yeah, I tried AddressSantizer since it helps in most cases, but when that is turned on i get a warning from the dav1d lib that aligned malloc is not available:
During my tons of reading I stumbled upon your comment in another issue where you mentioned that toggling features actually change the libc being used, so I would assume that sanitized libc does not conain this? Also I am now quite confused that the original author had @sbc100 sorry if I sound pushy, but may I contact you in the Discord channel at any convenient for you for more pointer? And thanks for all the answers so far. |
@sbc100 oh wow, removing |
Closing this since changing the allocator fixed, and +1 for the feature to have system libs with debug info. |
So I am getting
RuntimeError: memory access out of bounds
while trying to build dav1d to wasm. I forked an existing project which seems to be abandoned at the beginning of 2019 (and since I had to tweak a lot of build flags to make it work with the latest emscripten I assume it did work and maybe some breaking changes are causing this). My fork can be found here to see the build flags etc. Now that I have all the debug stuff enabled can nicely see the stack trace:It seems that inside SAFE_HEAP_LOAD_i32_4_4 the
i32.load
instruction is called with -4 on the stack, so the error makes sense. But that seems to happen inside libc. I'm attaching screenshots form each of the stack frames, but the call from the C code seems quite naive -posix_memalign
is called with 3536 as the size and 32 as the alignment, and those values seem to work in a trivial example. Also, mysegfault
handler is called befor that happens, which also makes sense since there is acall $segfault
in SAFE_HEAP_LOAD_i32_4_4 before the load. I would assume that to debug this I would need a wasm libc built with -g4 as well? How does one do that? I Googled a lot but the Emscripten pages mention building llvm but not the toolchain.Here is the faulting region in SAFE_HEAP_LOAD_i32_4_4:
Here is attempt_allocate:
Here is posix_memalign:
The text was updated successfully, but these errors were encountered: