I am trying to compile and use a shared C library as a python module and I am observing that depending on the DYLD_LIBRARY_PATH
my code works or it crashes with a cryptic error message.
Jul 24 02:44:44 master
$ DYLD_LIBRARY_PATH=/opt/local/lib python -c 'import opengm'
OKAY
Jul 24 02:45:41 master
$ DYLD_LIBRARY_PATH= python -c 'import opengm'
python(86214,0x7fff70ccdcc0) malloc: *** error for object 0x7fff70177500: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap
I have tried to manually inspect which libraries are common between /usr/lib
and /usr/local/lib
and /opt/local/lib
but I have not been able to find the cause of the crash. One way to figure out the cause of the problem will be to figure out which dylib
files do the two processes use? I was not able to figure this using opensnoop
or dtruss
but maybe I was using those tools wrong.
How can I figure out the cause of this crash?
You can set DYLD_PRINT_LIBRARIES=YES
in the environment to have dyld
print every dynamic library that it loads into the process:
$ DYLD_PRINT_LIBRARIES=YES /usr/bin/true
dyld: loaded: /usr/bin/true
dyld: loaded: /usr/lib/libSystem.B.dylib
[ ... snip ... ]
dyld: loaded: /usr/lib/libc++.1.dylib
dyld: loaded: /usr/lib/libDiagnosticMessagesClient.dylib
$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With