Skip to content

Commit ab63f7a

Browse files
authored
Ensure lsan is initialized (#20790)
This fixes lsan.test_pthread_exit_main_stub. I think this a bug upstream bug hasn't been noticed because it only shows up in some rare circumstances. - no dynamic memory allocation function is called (e.g. malloc/free) - pthread_create is not called - pthread_exit (or some other pthread API) *is* called - SANITIZER_CAN_USE_PREINIT_ARRAY is not defined
1 parent 1efebf3 commit ab63f7a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ jobs:
523523
asan.test_asyncify_longjmp
524524
lsan.test_stdio_locking
525525
lsan.test_dlfcn_basic
526-
lsan.test_pthread_create"
526+
lsan.test_pthread_create
527+
lsan.test_pthread_exit_main_stub"
527528
- freeze-cache
528529
- run-tests:
529530
# also run a single test of EMTEST_BROWSER=node.

system/lib/compiler-rt/lib/lsan/lsan_thread.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ void InitializeThreads() {
4545
thread_arg_retval = new (thread_arg_retval_placeholder) ThreadArgRetval();
4646
}
4747

48-
ThreadArgRetval &GetThreadArgRetval() { return *thread_arg_retval; }
48+
ThreadArgRetval &GetThreadArgRetval() {
49+
ENSURE_LSAN_INITED;
50+
return *thread_arg_retval;
51+
}
4952

5053
ThreadContextLsanBase::ThreadContextLsanBase(int tid)
5154
: ThreadContextBase(tid) {}

0 commit comments

Comments
 (0)