From a0b9031f6313cac5fa401e75c24702e59915adde Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Fri, 4 Dec 2020 13:04:29 +0100 Subject: [PATCH 1/3] Ensure Node worker threads are exited gracefully --- src/library_pthread.js | 5 ----- tests/test_posixtest.py | 21 +-------------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/src/library_pthread.js b/src/library_pthread.js index 995aee7dbb1b8..364b926e6e445 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -1055,11 +1055,6 @@ var LibraryPThread = { if (!ENVIRONMENT_IS_PTHREAD) _exit(status); else PThread.threadExit(status); // pthread_exit is marked noReturn, so we must not return from it. - if (ENVIRONMENT_IS_NODE) { - // exit the pthread properly on node, as a normal JS exception will halt - // the entire application. - process.exit(status); - } throw 'unwind'; }, diff --git a/tests/test_posixtest.py b/tests/test_posixtest.py index 2d006d4a64562..0712fceb9575c 100644 --- a/tests/test_posixtest.py +++ b/tests/test_posixtest.py @@ -146,26 +146,7 @@ def get_pthread_tests(): **unsupported, **flaky, 'test_pthread_create_11_1': 'never returns', - 'test_pthread_barrier_wait_2_1': 'never returns', 'test_pthread_attr_setscope_5_1': 'internally skipped (PTS_UNTESTED)', - 'test_pthread_create_5_1': 'never returns', - 'test_pthread_exit_1_2': 'never returns', - 'test_pthread_exit_2_2': 'never returns', - 'test_pthread_exit_3_2': 'never returns', - 'test_pthread_exit_4_1': 'never returns', - 'test_pthread_getcpuclockid_1_1': 'never returns', - 'test_pthread_key_create_1_2': 'never returns', - 'test_pthread_rwlock_rdlock_1_1': 'fails with "main: Unexpected thread state"', - 'test_pthread_rwlock_timedrdlock_1_1': 'fails with "main: Unexpected thread state"', - 'test_pthread_rwlock_timedrdlock_3_1': 'fails with "main: Unexpected thread state"', - 'test_pthread_rwlock_timedrdlock_5_1': 'fails with "main: Unexpected thread state"', - 'test_pthread_rwlock_timedwrlock_1_1': 'fails with "main: Unexpected thread state"', - 'test_pthread_rwlock_timedwrlock_3_1': 'fails with "main: Unexpected thread state"', - 'test_pthread_rwlock_timedwrlock_5_1': 'fails with "main: Unexpected thread state"', - 'test_pthread_rwlock_wrlock_1_1': 'fails with "main: Unexpected thread state"', - 'test_pthread_rwlock_trywrlock_1_1': 'fails with "main: Unexpected thread state"', - 'test_pthread_spin_destroy_3_1': 'never returns', - 'test_pthread_spin_init_4_1': 'never returns', } @@ -180,7 +161,7 @@ def f(self): '-Wno-int-conversion', '-sUSE_PTHREADS', '-sEXIT_RUNTIME', - '-sTOTAL_MEMORY=268435456', + '-sTOTAL_MEMORY=256mb', '-sPTHREAD_POOL_SIZE=40'] if browser: # Only are only needed for browser tests of the was btest From eee663ad0e0099194d15376a0c068a6a4592b064 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Fri, 18 Jun 2021 14:54:24 +0200 Subject: [PATCH 2/3] posixtest.test_pthread_create_11_1 seems to work again --- tests/test_posixtest.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_posixtest.py b/tests/test_posixtest.py index 0712fceb9575c..112a1e52e8a8f 100644 --- a/tests/test_posixtest.py +++ b/tests/test_posixtest.py @@ -136,7 +136,7 @@ def get_pthread_tests(): } # Mark certain tests as flaky, which may sometimes fail. -# TODO invesigate these tests. +# TODO investigate these tests. flaky = { 'test_pthread_cond_signal_1_1': 'flaky: https://github.com/emscripten-core/emscripten/issues/13283', } @@ -145,7 +145,6 @@ def get_pthread_tests(): disabled = { **unsupported, **flaky, - 'test_pthread_create_11_1': 'never returns', 'test_pthread_attr_setscope_5_1': 'internally skipped (PTS_UNTESTED)', } From 20a7b8a7914c32871e3151b8bd288183685befec Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Fri, 18 Jun 2021 14:57:58 +0200 Subject: [PATCH 3/3] Explicitly link test_pthread* tests with EXIT_RUNTIME Somehow these tests hang infinitely without using this setting. This was not necessary before the rebase. --- tests/test_core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_core.py b/tests/test_core.py index 11237af6a6b64..daad84c4de62f 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -8246,6 +8246,7 @@ def test_pthread_cxx_threads(self): def test_pthread_create_pool(self): # with a pool, we can synchronously depend on workers being available self.set_setting('PTHREAD_POOL_SIZE', '2') + self.set_setting('EXIT_RUNTIME') self.emcc_args += ['-DALLOW_SYNC'] self.do_run_in_out_file_test('core/pthread/create.cpp') @@ -8261,12 +8262,14 @@ def test_pthread_create_proxy(self): def test_pthread_create_embind_stack_check(self): # embind should work with stack overflow checks (see #12356) self.set_setting('STACK_OVERFLOW_CHECK', 2) + self.set_setting('EXIT_RUNTIME') self.emcc_args += ['--bind'] self.do_run_in_out_file_test('core/pthread/create.cpp') @node_pthreads def test_pthread_exceptions(self): self.set_setting('PTHREAD_POOL_SIZE', '2') + self.set_setting('EXIT_RUNTIME') self.emcc_args += ['-fexceptions'] self.do_run_in_out_file_test('core/pthread/exceptions.cpp')