Robert
Robert

Reputation: 160

AddressSanitizer command line builds always results in "symbol missing" error during runtime

I build a command line tool with xcodebuild but when running my cli tool in Terminal I always get the output:

rwelz@Big-Sur-Mac ~ % TPAutoConnect
TPAutoConnect(1963,0x1139b1600) malloc: nano zone abandoned due to inability to preallocate reserved vm space.
dyld[1963]: missing symbol called
zsh: abort TPAutoConnect

I have imho already tried every link and compile flag the internet suggests by now.

The stack trace part of the crash log looks like

Termination Reason:    Namespace DYLD, Code 4 Symbol missing
missing symbol called
(terminated at launch; ignore backtrace)

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   dyld                                   0x11397798e __abort_with_payload + 10
1   dyld                                   0x11398da72 abort_with_payload_wrapper_internal + 80
2   dyld                                   0x11398daa4 abort_with_payload + 9
3   dyld                                   0x11393b699 dyld4::halt(char const*) + 615
4   dyld                                   0x113958164 dyld4::APIs::_dyld_missing_symbol_abort() + 34
5   TPAutoConnect                          0x10ee0056b asan.module_ctor + 11
6   dyld                                   0x11396c911 invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 129
7   dyld                                   0x113963e26 invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 557
8   dyld                                   0x113932db3 dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 129
9   dyld                                   0x113963bb7 dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 179
10  dyld                                   0x11396c342 dyld3::MachOAnalyzer::forEachInitializerPointerSection(Diagnostics&, void (unsigned int, unsigned int, unsigned char const*, bool&) block_pointer) const + 118
11  dyld                                   0x11396c5b4 dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 386
12  dyld                                   0x113945d82 dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 144
13  dyld                                   0x113945f0e dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 178
14  dyld                                   0x113945fb2 dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const + 108
15  dyld                                   0x113959826 dyld4::APIs::runAllInitializersForMain() + 222
16  dyld                                   0x11393738d dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 3443
17  dyld                                   0x1139364e4 start + 388

I tried xcodebuild … -enableAddressSanitizer YES
setting Other Linker Flags and Other C Flags in xcode to -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fsanitize-address
adding -shared-libasan
and any combination of these flags.

I am not compiling and running on the same machine, I am using Xcode 12.3. to compile and build but I am running the cli program on macos 13.4.1

Can someone help, please?

Upvotes: 0

Views: 246

Answers (1)

Robert
Robert

Reputation: 160

The problem was a silly one: The binaries were build on a Jenkins build server with Xcode 12.3 (on macOS 10.15.7). I tried to run the binaries on a mac with Xcode 14.3.1 (on macOS 13.4.1). Since libclang_rt.asan_osx_dynamic.dylib is part of Xcode it is

  1. not found inside the recent Xcode app and
  2. when tricking by setting a symlink to the dylib it shows a missing symbol which really means the more recent dylib is incompatible.

Now I rolled out the binaries on a mac with same macOS and same Xcode (12.3) as the build was made on, ASAN works "out of the box".

Now lets see if it is possible to include the dylib in my installer to debug my binaries on every macOS version possible.

Upvotes: 0

Related Questions