On MacOS, I have a set of python
binaries I don't control (i.e. I can't build them with LDFLAGS='-undefined error'
).
On certain MacOS hosts/architectures (that is, some ARM Macs, but not all of them; some x86 Macs, but not all of them), doing certain things in Python fails with dyld[some_pid]: missing symbol called
.
How can I find out which library file is causing the issue, and which symbol, by name, is missing?
Using the below environment displays dyld
's diagnostic output:
DYLD_PRINT_LIBRARIES=1
DYLD_PRINT_APIS=1
DYLD_PRINT_WARNINGS=1
That causes the failed operations to emit what seem to be successful dyld
operations before the crash. But the diagnostic output isn't sufficient; for example, it often looks like this:
dyld[91757]: dyld_image_path_containing_address(0x10a7ab000) => '/path/to/python/lib/lib.macosx-10.15-x86_64-3.7/_csv.cpython-37m-darwin.so'
dyld[91757]: _dyld_is_memory_immutable(0x10a7ab000, 28) => 0
dyld[91757]: dlopen(_csv.cpython-37m-darwin.so) => 0x210fbb0c0
dyld[91757]: dlsym(0x210fbb0c0, "PyInit__csv")
dyld[91757]: dlsym("PyInit__csv") => 0x10a7abbc0
dyld[91757]: missing symbol called
In that example, nm
reports that _csv.cpython-37m-darwin.so
can resolve a symbol called PyInit__csv
. So it seems (I think) like the missing symbol called
error is failing on a different symbol, but I don't know how to determine which one that is.
I'm by no means an expert but:
I'd much rather get
dydl
to tell me what symbol it couldn't find
Have you tried with
export DYLD_PRINT_BINDINGS=1
from the apple developer resource (https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/LoggingDynamicLoaderEvents.html)
it states: DYLD_PRINT_BINDINGS Logs when the dynamic loader binds an undefined external symbol with its definition.
I tried cretaing a c binary which calls an undefined symbol, and the output after
export DYLD_PRINT_BINDINGS=1
is
dyld[2870]: <A36F4B15-ACF6-3C57-A5F9-125B99BCACF8> /Users/admin/Desktop/Projects/dydl/libmissing.dylib
dyld[2870]: <libmissing.dylib/bind#0> -> 0x183b8b4a0 (libdyld.dylib/dyld_stub_binder)
dyld[2870]: <libmissing.dylib/bind#1> -> 0x0 (<none>/_missing_function)
which means:
The library is fully loaded
dyld[2870]: <A36F4B15-ACF6-3C57-A5F9-125B99BCACF8> /Users/admin/Desktop/Projects/dydl/libmissing.dylib
Tries to call _missing_function but it fails (0x0)
dyld[2870]: <libmissing.dylib/bind#1> -> 0x0 (<none>/_missing_function)
which is indeed the function i programmed to throw the error
#include <stdio.h>
void missing_function(); // Declare the missing function
void call_missing_function() {
printf("Calling missing_function...\n");
missing_function(); // Attempt to call the undefined function
}