Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/lib/libpthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,7 @@ var LibraryPThread = {
// the worker is now dead and we don't want to hear from it again, so we stub
// out its message handler here. This avoids having to check in each of
// the onmessage handlers if the message was coming from a valid worker.
worker.onmessage = (e) => {
#if ASSERTIONS
var cmd = e.data.cmd;
err(`received "${cmd}" command from terminated worker: ${worker.workerID}`);
#endif
};
worker.onmessage = () => {};
},

_emscripten_thread_cleanup: (thread) => {
Expand Down
36 changes: 36 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -13446,6 +13446,42 @@ def test_pthread_callback_alignment(self):
def test_pthread_join_interrupted(self):
self.do_runf('pthread/test_pthread_join_interrupted.c', cflags=['-pthread'])

@requires_pthreads
def test_pthread_proxied_join_and_exit(self):
# Check that expected lifecycle messages coming from terminated workers do
# not log warnings.
create_file('test_pthread_proxied_join_and_exit.c', r'''
#include <pthread.h>
#include <emscripten/console.h>

void* thread_main(void* arg) {
emscripten_console_log("worker");
return NULL;
}

int main() {
pthread_t t1, t2, t3;
pthread_create(&t1, NULL, thread_main, NULL);
pthread_create(&t2, NULL, thread_main, NULL);
pthread_create(&t3, NULL, thread_main, NULL);

pthread_join(t1, NULL);
pthread_join(t2, NULL);
pthread_join(t3, NULL);

return 0;
}
''')

out_js = self.in_dir('test_pthread_proxied_join_and_exit.js')
self.run_process([
EMCC, '-pthread', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME', '-sASSERTIONS',
'test_pthread_proxied_join_and_exit.c', '-o', out_js,
])

output = self.run_js(out_js)
self.assertEqual(output.splitlines(), ['worker', 'worker', 'worker'])

@requires_node_26
def test_growable_arraybuffers(self):
self.do_runf('hello_world.c',
Expand Down
Loading