diff options
| author | Kuba Brecka <kuba.brecka@gmail.com> | 2016-03-28 19:36:25 +0000 |
|---|---|---|
| committer | Kuba Brecka <kuba.brecka@gmail.com> | 2016-03-28 19:36:25 +0000 |
| commit | 0d026d9e9eb4fa1695dc94be43f02579f59bc696 (patch) | |
| tree | 06983f13be8965d0f3a2b167716d63177844a14a /compiler-rt/lib/tsan | |
| parent | 7434e1d01f4d0b07ea2073c3b9dcdaa35b505805 (diff) | |
| download | bcm5719-llvm-0d026d9e9eb4fa1695dc94be43f02579f59bc696.tar.gz bcm5719-llvm-0d026d9e9eb4fa1695dc94be43f02579f59bc696.zip | |
[tsan] Fix a crash when exiting the main thread (e.g. dispatch_main)
This patch fixes the custom ThreadState destruction on OS X to avoid crashing when dispatch_main calls pthread_exit which quits the main thread.
Differential Revision: http://reviews.llvm.org/D18496
llvm-svn: 264627
Diffstat (limited to 'compiler-rt/lib/tsan')
| -rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_platform_mac.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cc b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cc index 31caf37dee5..6109ef28b33 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cc @@ -91,7 +91,11 @@ ThreadState *cur_thread() { // handler will try to access the unmapped ThreadState. void cur_thread_finalize() { uptr thread_identity = (uptr)pthread_self(); - CHECK_NE(thread_identity, main_thread_identity); + if (thread_identity == main_thread_identity) { + // Calling dispatch_main() or xpc_main() actually invokes pthread_exit to + // exit the main thread. Let's keep the main thread's ThreadState. + return; + } ThreadState **fake_tls = (ThreadState **)MemToShadow(thread_identity); internal_munmap(*fake_tls, sizeof(ThreadState)); *fake_tls = nullptr; |

