Skip to content

Commit e81f854

Browse files
authored
[test] Deflake test_pthread_kill (#27819)
Remove the racing `printf("SIGTERM sent\n")` call on the main thread immediately after `pthread_kill(child_thread, SIGTERM)`, which raced with `child_thread` printing from its `SIGTERM` signal handler. Also wait for `got_sigusr1` before `pthread_join` so all output lines have a strict happens-before ordering. Fixes: #24725
1 parent 941e514 commit e81f854

3 files changed

Lines changed: 2 additions & 7 deletions

File tree

‎test/pthread/test_pthread_kill.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,11 @@ int main() {
7676

7777
s = pthread_kill(child_thread, SIGTERM);
7878
assert(s == 0);
79-
printf("SIGTERM sent\n");
8079

81-
pthread_join(child_thread, NULL);
82-
printf("joined child_thread\n");
8380
while (!got_sigusr1) {
8481
sleepms(1);
8582
}
86-
printf("got SIGUSR1. all done.\n");
83+
pthread_join(child_thread, NULL);
84+
printf("joined child_thread\n");
8785
return 0;
8886
}

‎test/pthread/test_pthread_kill.out‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
tesing pthread_kill with pthread_self
22
signal: 15 onthread=0
33
thread has started, sending SIGTERM
4-
SIGTERM sent
54
signal: 15 onthread=1
65
got term signal, sending signal back to main thread
76
signal: 10 onthread=0
87
joined child_thread
9-
got SIGUSR1. all done.

‎test/test_other.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13620,7 +13620,6 @@ def test_pthread_trap(self):
1362013620
self.assertContained('at (test_pthread_trap.wasm.)?thread_main', output, regex=True)
1362113621

1362213622
@requires_pthreads
13623-
@flaky('https://github.com/emscripten-core/emscripten/issues/24725')
1362413623
def test_pthread_kill(self):
1362513624
self.do_runf_out_file('pthread/test_pthread_kill.c')
1362613625

0 commit comments

Comments
 (0)