Skip to content

Commit b986343

Browse files
committed
[NFC] Remove Win specific Destroy from ThreadStart
1 parent 6674e57 commit b986343

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

compiler-rt/lib/asan/asan_thread.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -288,17 +288,7 @@ thread_return_t AsanThread::ThreadStart(tid_t os_id) {
288288
return 0;
289289
}
290290

291-
thread_return_t res = start_routine_(arg_);
292-
293-
// On POSIX systems we defer this to the TSD destructor. LSan will consider
294-
// the thread's memory as non-live from the moment we call Destroy(), even
295-
// though that memory might contain pointers to heap objects which will be
296-
// cleaned up by a user-defined TSD destructor. Thus, calling Destroy() before
297-
// the TSD destructors have run might cause false positives in LSan.
298-
if (!SANITIZER_POSIX)
299-
this->Destroy();
300-
301-
return res;
291+
return start_routine_(arg_);
302292
}
303293

304294
AsanThread *CreateMainThread() {

compiler-rt/lib/asan/asan_win.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ INTERCEPTOR(int, _except_handler4, void *a, void *b, void *c, void *d) {
134134
static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
135135
AsanThread *t = (AsanThread *)arg;
136136
SetCurrentThread(t);
137-
return t->ThreadStart(GetTid());
137+
auto res = t->ThreadStart(GetTid());
138+
t->Destroy(); // POSIX calls this from TSD destructor.
139+
return rest;
138140
}
139141

140142
INTERCEPTOR_WINAPI(HANDLE, CreateThread, LPSECURITY_ATTRIBUTES security,

0 commit comments

Comments
 (0)