5

I'm trying to use the Thread Sanitizer in Xcode 11.2.1 but whenever the app launches (just a single view app from Xcode's template, nothing added) it hits __abort_with_payload:

libsystem_kernel.dylib`__abort_with_payload:
     0x7fff51b73be0 <+0>:  movl   $0x2000209, %eax          ; imm = 0x2000209 
     0x7fff51b73be5 <+5>:  movq   %rcx, %r10
     0x7fff51b73be8 <+8>:  syscall 
 ->  0x7fff51b73bea <+10>: jae    0x7fff51b73bf4            ; <+20>
     0x7fff51b73bec <+12>: movq   %rax, %rdi
     0x7fff51b73bef <+15>: jmp    0x7fff51b54a89            ; cerror_nocancel
     0x7fff51b73bf4 <+20>: retq   
     0x7fff51b73bf5 <+21>: nop    
     0x7fff51b73bf6 <+22>: nop    
     0x7fff51b73bf7 <+23>: nop

None of Apple's docs or other people's guides to using the Thread Sanitizer say you need to do anything more than tick the box in the scheme's settings but for me that doesn't work :(

Printing out $arg5 gives

pthread_t was corrupted

which doesn't sound great!

This is on Catalina 10.15.2 using the iPhone 11 Pro Max simulator

CMash
  • 1,987
  • 22
  • 35

3 Answers3

5

This issue has been fixed as of Xcode 11.3.1, thanks to vandzi for pointing it out!

CMash
  • 1,987
  • 22
  • 35
0

I also faced similar issue, Thread Sanitizer was ON in scheme settings and turning that off solved the problem in my case.

Abdullah Md. Zubair
  • 3,312
  • 2
  • 30
  • 39
0

Looks like it is connected to this tsan commit https://github.com/llvm/llvm-project/commit/f9a706a36ae5dcb87b0b6649d0c80e989400f48e

https://reviews.llvm.org/D71559

I need to run thread sanitizer very badly, so built the newest llvm with

> mkdir workspace/
> git clone https://github.com/llvm/llvm-project.git
> cd llvm-project; mkdir build; cd build 

>cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;libcxx;libcxxabi;libunwind;lldb;compiler-rt;lld;polly' -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=$HOME/llvm -DLLVM_ENABLE_DUMP=ON # not everything is needed though here

>ninja

and replaced

~/Library/Developer/CoreSimulator/Devices/C0E36E0C-C22A-426E-80B7-557164B2FBD3/data/Containers/Bundle/Application/D6D4D9DB-4C26-4FA0-8363-5CA03A47B6C0/Spotify.app/Frameworks/libclang_rt.tsan_iossim_dynamic.dylib

with the newly built lib from

/workspace/llvm-project/build/lib/clang/10.0.0/lib/darwin/libclang_rt.tsan_iossim_dynamic.dylib # 10.0.0 is the previos version some artifact of my bulding, it had the fixed revision ^

the app seem to load in the simulator and not crash with

Thread 0 Crashed:
0   libsystem_kernel.dylib          0x00007fff523d5bea __abort_with_payload + 10
1   libsystem_kernel.dylib          0x00007fff523d74f3 abort_with_payload_wrapper_internal + 80
2   libsystem_kernel.dylib          0x00007fff523d74a3 abort_with_reason + 19
3   libsystem_pthread.dylib         0x00007fff52469974 pthread_self.cold.1 + 24
4   libsystem_pthread.dylib         0x00007fff52462fe3 pthread_self + 34
5   libclang_rt.tsan_iossim_dynamic.dylib   0x000000013b59816b __tsan::cur_thread() + 11
6   libclang_rt.tsan_iossim_dynamic.dylib   0x000000013b56d985 wrap_sysctlbyname + 37
7   libsystem_sim_kernel.dylib      0x00007fff52470331 assert_simulator_supported_host + 44
8   libSystem.B.dylib               0x00007fff4ff167c1 libSystem_initializer + 78
9   dyld_sim                        0x000000013b3a73a7 ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) + 517

any more! my app seems to show the first screen but freeze afterwards, so not sure its completely workable.

hope that helps