How to find which shared library is loaded by a process on OSX? 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? 

DISCLAIMER: I posted this same question on SO 2 days ago, where it did not receive any replies and only 8 views.
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
$