Correct detection of a thread termination
authorKamil Rytarowski <n54@gmx.com>
Fri, 3 Nov 2017 20:48:19 +0000 (20:48 +0000)
committerKamil Rytarowski <n54@gmx.com>
Fri, 3 Nov 2017 20:48:19 +0000 (20:48 +0000)
commit55435b74271433e1767bb4f6d192f273862ff698
tree87171fb7b655ddc002fdbfd4f4cb5bf156abb2be
parent0c99007db1b31d5d00c449ad2af2dd9bda051844
Correct detection of a thread termination

Summary:
Stop using the Linux solution with pthread_key_create(3).
This approach does not work on NetBSD, because calling
the thread destructor is not the latest operation on a POSIX
thread entity. NetBSD's libpthread still calls at least
pthread_mutex_lock and pthread_mutex_unlock.

Detect _lwp_exit(2) call as it is really the latest operation
called from a detaching POSIX thread.

This resolves one set of crashes observed in
the Thread Sanitizer execution.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, kcc, vitalybuka, dvyukov, eugenis

Reviewed By: vitalybuka

Subscribers: llvm-commits, kubamracek, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D39618

llvm-svn: 317363
compiler-rt/lib/tsan/rtl/tsan_interceptors.cc