Skip to content

Commit 82a8f2d

Browse files
authored
Fix keepRuntimeAlive for pthreads (#22927)
Fixes: #22889
1 parent 929698b commit 82a8f2d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/library.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -2078,16 +2078,12 @@ addToLibrary({
20782078
// at runtime.
20792079
$keepRuntimeAlive__deps: ['$runtimeKeepaliveCounter'],
20802080
$keepRuntimeAlive: () => noExitRuntime || runtimeKeepaliveCounter > 0,
2081-
#elif !EXIT_RUNTIME
2082-
// When `noExitRuntime` is not include and EXIT_RUNTIME=0 then we know the
2081+
#elif !EXIT_RUNTIME && !PTHREADS
2082+
// When `noExitRuntime` is not included and EXIT_RUNTIME=0 then we know the
20832083
// runtime can never exit (i.e. should always be kept alive).
2084-
// However for pthreads we always default to allowing the runtime to exit
2085-
// otherwise threads never exit and are not joinable.
2086-
#if PTHREADS
2087-
$keepRuntimeAlive: () => !ENVIRONMENT_IS_PTHREAD,
2088-
#else
2084+
// However, since pthreads themselves always need to be able to exit we
2085+
// have to track `runtimeKeepaliveCounter` in that case.
20892086
$keepRuntimeAlive: () => true,
2090-
#endif
20912087
#else
20922088
$keepRuntimeAlive__deps: ['$runtimeKeepaliveCounter'],
20932089
$keepRuntimeAlive: () => runtimeKeepaliveCounter > 0,

test/test_other.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -13640,8 +13640,12 @@ def test_pthread_icu(self):
1364013640
self.do_other_test('test_pthread_icu.cpp')
1364113641

1364213642
@node_pthreads
13643-
def test_pthread_set_main_loop(self):
13644-
self.do_other_test('test_pthread_set_main_loop.c')
13643+
@parameterized({
13644+
'': ([],),
13645+
'strict': (['-sSTRICT'],),
13646+
})
13647+
def test_pthread_set_main_loop(self, args):
13648+
self.do_other_test('test_pthread_set_main_loop.c', emcc_args=args)
1364513649

1364613650
# unistd tests
1364713651

0 commit comments

Comments
 (0)