coz
coz copied to clipboard
Segmentation Fault, jemalloc interaction?
It appears Coz interacts poorly with jemalloc, causing the stack to explode. This makes it hard to use on Rust programs.
To reproduce: There's probably an easier way, but...
$ git clone https://github.com/TeXitoi/benchmarksgame-rs
...install deps as required
$ make
$ ulimit -c unlimited # so you get a core
$ bin/spectralnorm
1.274219991
$ coz run --- ./bin/spectralnorm
$ gdb ./bin/spectralnorm -c core
$ bt
#0 0x00007efefa94857d in pthread_mutex_lock (mutex=0x561e8f1d40f0 <init_lock>) at libcoz.cpp:268
#1 0x0000561e8ef94f63 in je_malloc_mutex_lock (tsdn=
I don't know much about coz yet, but @mjmeehan how did you add program markers to Rust for measuring component segments? Or where you not able to get that far?
I have the same question as jadbox, is it possible to add markers to a rust program?
https://github.com/alexcrichton/coz-rs
if someone can reproduce this, can you post the bottom few dozen frames of the stack?
The problem here is recursion between the dynamic linker, jemalloc and Coz's interposition code: the dynamic linker is trying to resolve a symbol, it calls calloc
, calloc needs pthread_mutex_lock
, Coz normally interposes on pthread_mutex_lock
, so the first time it calls, it needs to ask the dynamic linker where the libc version of the function is. This brings us to our infinite loop where we quickly blow the stack and crash.
Knowing what the top of the stack looks like might help figure out what sort of workaround is needed
I think I am having the same issue when using coz with a C program when jemalloc is linked. For me, simply adding -ljemalloc
to any of the included demo programs in the benchmarks folder is enough to cause it to crash during starting up.
This can be closed as a duplicate of more general issue #176