[libc-commits] [libc] f2c7e2b - [libc] Fix atexit_test in hermetic mode (#210656)
via libc-commits
libc-commits at lists.llvm.org
Mon Jul 27 23:20:11 PDT 2026
Author: Pavel Labath
Date: 2026-07-28T08:20:07+02:00
New Revision: f2c7e2bcd57ef2a9db23e5071618d3e02ee9c33d
URL: https://github.com/llvm/llvm-project/commit/f2c7e2bcd57ef2a9db23e5071618d3e02ee9c33d
DIFF: https://github.com/llvm/llvm-project/commit/f2c7e2bcd57ef2a9db23e5071618d3e02ee9c33d.diff
LOG: [libc] Fix atexit_test in hermetic mode (#210656)
We never unlocked the ThreadAtExit mutex, which meant the second call to
exit deadlocked. This was detected in the unit tests as they were
calling __cxa_thread_atexit from the system C library.
Added:
Modified:
libc/src/__support/threads/thread.cpp
libc/test/src/stdlib/CMakeLists.txt
Removed:
################################################################################
diff --git a/libc/src/__support/threads/thread.cpp b/libc/src/__support/threads/thread.cpp
index ae179f068b88e..babcfdc5aea15 100644
--- a/libc/src/__support/threads/thread.cpp
+++ b/libc/src/__support/threads/thread.cpp
@@ -131,6 +131,7 @@ class ThreadAtExitCallbackMgr {
atexit_unit.callback(atexit_unit.obj);
mtx.lock();
}
+ mtx.unlock();
}
};
diff --git a/libc/test/src/stdlib/CMakeLists.txt b/libc/test/src/stdlib/CMakeLists.txt
index 4a0d7a6abd910..188a1508eb645 100644
--- a/libc/test/src/stdlib/CMakeLists.txt
+++ b/libc/test/src/stdlib/CMakeLists.txt
@@ -530,8 +530,6 @@ if(LLVM_LIBC_FULL_BUILD AND LIBC_TEST_SUBPROCESS_TESTS)
add_libc_test(
atexit_test
- # TODO: Fix this test in hermetic mode.
- UNIT_TEST_ONLY
SUITE
libc-stdlib-tests
SRCS
More information about the libc-commits
mailing list