You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
App linked against jemalloc crashes freeing result of realpath #226
After fixing #225, the E4S chapel no longer hangs at startup, but the test instead segfaults later during execution. The problem occurs when the Chapel runtime calls realpath with resolved_path = NULL. Upon freeing the realpath-allocated return value, there is a crash in jemalloc.
The backtrace shows the crash on line 11, in the call to free:
#00x00007c674849018a in ?? () from /lib/x86_64-linux-gnu/libjemalloc.so.2
#10x00005e21bc02c22c in main () at test.c:11
It appears that Spindle is allocating with the malloc from libc, which then causes a crash in jemalloc's free when it is passed an address allocated by libc, not jemalloc
Aw. That makes sense and an issue. When emulating some of the calls like realpath() we hardcode to calling malloc in libc. But instead we need to search-for and use the same malloc that the app is referencing. I think you've got a couple choices:
Do an in-order search of the link maps checking each DSO if it exports the malloc family, and make the first one found our malloc instance.
IIRC, the symbind LD_AUDIT callbacks can tell you what symbol instance was being bound to. When we see one of those for a malloc family, we start using that instance for spindle's calls.
Activity
mplegendre commentedon Oct 2, 2026
Aw. That makes sense and an issue. When emulating some of the calls like realpath() we hardcode to calling malloc in libc. But instead we need to search-for and use the same malloc that the app is referencing. I think you've got a couple choices: