Skip to content

Commit a66571b

Browse files
committed
Fix flaky run_irt_ext_libc_test_irt
It was flaky because the IRT thread exit hook really hooks the thread exit syscall rather than pthread_exit. So the hook can surprisingly run after the thread is already joinable.
1 parent ab09db9 commit a66571b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎tests/irt_ext/libc/thread_tests.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ static int do_thread_creation_test(struct threading_environment *env) {
120120
return 1;
121121
}
122122

123+
/*
124+
* The IRT thread exit hook is called near the end of pthread_exit, after
125+
* the pthread implementation already marked the thread dead. So it can
126+
* still be running after the thread was joined. Note: num_threads_exited
127+
* is declared volatile.
128+
*/
129+
while (env->num_threads_exited == 0) {}
130+
123131
if (env->num_threads_exited != 1) {
124132
irt_ext_test_print("do_thread_creation_test: Thread Exit was not"
125133
" recorded in the environment.\n");

0 commit comments

Comments
 (0)