Open raincoats opened 7 years ago
Thank you for a detailed description! The issue is that printf
on your machine internally depends on malloc
. This creates a recursion resulting in a segmentation fault.
A possible fix that comes to my mind is to set a particular variable before calling external functions. Also, within malloc, redirecting calls of to __libc_malloc
whenever that variable is set. Though, I guess it'll create problems in mutexes. l I'll think over it and let you know when I fix it.
this is the output of make rundtests on arch, it works
test buffer_overflow [LIBDHEAP LOG] : Buffer overflow detected in heap chunk [LIBDHEAP LOG] : Inconsistent heap canary! [LIBDHEAP LOG] : Printing Stack Trace ====> [LIBDHEAP LOG] : 0x400565 [LIBDHEAP LOG] : 0x7f89f0b8a43a [LIBDHEAP LOG] : <==== End of Stack Trace
buffer_underflow [LIBDHEAP LOG] : Buffer underflow detected in heap chunk [LIBDHEAP LOG] : Inconsistent heap canary! [LIBDHEAP LOG] : Printing Stack Trace ====> [LIBDHEAP LOG] : 0x400574 [LIBDHEAP LOG] : 0x7f5c0969143a [LIBDHEAP LOG] : <==== End of Stack Trace
double_free [LIBDHEAP LOG] : Freeing non allocated chunk! [LIBDHEAP LOG] : Printing Stack Trace ====> [LIBDHEAP LOG] : 0x400596 [LIBDHEAP LOG] : 0x7fedd560843a [LIBDHEAP LOG] : <==== End of Stack Trace
yes the problem seems to be the malloc used in the printf, but I don't have any fix in mind at the moment..
Hi, I'm getting segfaults when running any program with this library LD_PRELOADed.
I first compiled it normally, then when it didn't work, I unset all environment variables to be sure it wasn't some strange setting on my machine, but that didn't help at all.
Additionally,
make runtests
seems to work butmake rundtests
doesn't.Running
LD_PRELOAD=$(pwd)/libdheap.so LIBDHEAP_DEBUG=1 ./test
, and then usinggdb
to analyse the coredump shows me that there was 63589 stack frames, basically just looping these:Shell output
Compiling and running the tests Output of running the command (with a reduced stack size (256), otherwise it's huge) Output of
bt full
ingdb
(again with reduced stack size)My machine