From 9ac653be3e1b1ac04ef2662bdc59c75a1e1906b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Michal?= Date: Wed, 26 Nov 2025 03:19:19 +0100 Subject: [PATCH 1/3] Swap mutex unlock and condition_variable notify_all at thread exit. --- stl/src/xnotify.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/src/xnotify.cpp b/stl/src/xnotify.cpp index 96aebb485b2..a49c88917b8 100644 --- a/stl/src/xnotify.cpp +++ b/stl/src/xnotify.cpp @@ -93,8 +93,8 @@ _CRTIMP2_PURE void __cdecl _Cnd_do_broadcast_at_thread_exit() noexcept { if (block->data[i].res) { *block->data[i].res = 1; } - _Mtx_unlock(block->data[i].mtx); _Cnd_broadcast(block->data[i].cnd); + _Mtx_unlock(block->data[i].mtx); block->data[i].mtx = nullptr; --block->num_used; } From 24fda938aad5348b7fe625b93a461e0ea2ebe9e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20Michal?= Date: Wed, 26 Nov 2025 10:28:54 +0100 Subject: [PATCH 2/3] Don't skip libcpp test std/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp --- tests/libcxx/expected_results.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 23dcd2bbca2..d1cd86523b7 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -610,9 +610,7 @@ std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.p std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/release_reset_initial_status.pass.cpp FAIL # LWG-3343 "Ordering of calls to unlock() and notify_all() in Effects element of notify_all_at_thread_exit() should be reversed" (Open) -# libc++ speculatively implements LWG-3343. If we wanted to do the same thing, -# we'd need to reverse the order of the _Mtx_unlock() and _Cnd_broadcast() calls in xnotify.cpp. -std/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp SKIPPED +std/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp PASS # *** C1XX COMPILER BUGS *** From f058a914d4f65ddce6f5801411264ff40e9eb5d7 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 5 Dec 2025 16:32:37 -0800 Subject: [PATCH 3/3] YOU SHALL PASS! --- tests/libcxx/expected_results.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index fd989e58789..08edafbe22b 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -626,9 +626,6 @@ std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.p # LWG-3120 Unclear behavior of monotonic_buffer_resource::release() std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.mem/release_reset_initial_status.pass.cpp FAIL -# LWG-3343 "Ordering of calls to unlock() and notify_all() in Effects element of notify_all_at_thread_exit() should be reversed" (Open) -std/thread/thread.condition/notify_all_at_thread_exit_lwg3343.pass.cpp PASS - # *** C1XX COMPILER BUGS *** # DevCom-1436243 VSO-1335743 constexpr new initialized array