summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/lsan/lsan_thread.cc
diff options
context:
space:
mode:
authorSergey Matveev <earthdok@google.com>2013-07-08 12:57:24 +0000
committerSergey Matveev <earthdok@google.com>2013-07-08 12:57:24 +0000
commitbdeff959a166594abf76206d0eae397e4cc17747 (patch)
treeaf6b1dc3d1afef208ba86f9bddca36067e428d77 /compiler-rt/lib/lsan/lsan_thread.cc
parent86142e02df74b8a4b3cb696818c31ff064f1bc45 (diff)
downloadbcm5719-llvm-bdeff959a166594abf76206d0eae397e4cc17747.tar.gz
bcm5719-llvm-bdeff959a166594abf76206d0eae397e4cc17747.zip
[lsan] Handle fork() correctly.
Update the main thread's os_id on every pthread_create, and before initiating leak checking. This ensures that we have the correct os_id even if we have forked after Init(). llvm-svn: 185815
Diffstat (limited to 'compiler-rt/lib/lsan/lsan_thread.cc')
-rw-r--r--compiler-rt/lib/lsan/lsan_thread.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler-rt/lib/lsan/lsan_thread.cc b/compiler-rt/lib/lsan/lsan_thread.cc
index 3e28dee1325..3bfccdf712d 100644
--- a/compiler-rt/lib/lsan/lsan_thread.cc
+++ b/compiler-rt/lib/lsan/lsan_thread.cc
@@ -123,6 +123,11 @@ void ThreadJoin(u32 tid) {
thread_registry->JoinThread(tid, /* arg */0);
}
+void EnsureMainThreadIDIsCorrect() {
+ if (GetCurrentThread() == 0)
+ CurrentThreadContext()->os_id = GetTid();
+}
+
///// Interface to the common LSan module. /////
bool GetThreadRangesLocked(uptr os_id, uptr *stack_begin, uptr *stack_end,
OpenPOWER on IntegriCloud