htl: Make sure the exit path of last thread sees all thread cleanups

In case e.g. some atexit() handlers expect all threads to have finished
their side effects.

Reported-by: Brent Baccala <cosine@freesoft.org> 's Claude assistant
This commit is contained in:
Samuel Thibault
2026-03-08 18:19:19 +01:00
parent 9ec6f2d466
commit b874221766
+1 -1
View File
@@ -60,7 +60,7 @@ __pthread_exit (void *status)
/* Decrease the number of threads. We use an atomic operation to
make sure that only the last thread calls `exit'. */
if (atomic_fetch_add_relaxed (&__pthread_total, -1) == 1)
if (atomic_fetch_add_acq_rel (&__pthread_total, -1) == 1)
/* We are the last thread. */
exit (0);