Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix keepRuntimeAlive in the case where EXIT_RUNTIME=0 and noExitRuntime is not referenced #22542

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Sep 9, 2024

Essentially the keepRuntimeAlive was relying on the noExitRuntime variable being set based on EXIT_RUNTIME but when noExitRuntime was absent the EXIT_RUNTIME settings was being ignored and the runtime was exiting even though EXIT_RUNTIME=0 was set (the default).

Fixes: #20636

@sbc100 sbc100 requested a review from kripken September 9, 2024 19:02
src/library.js Show resolved Hide resolved
@sbc100 sbc100 force-pushed the noExitRuntime branch 4 times, most recently from 47833bf to 0fed818 Compare September 9, 2024 22:03
@sbc100 sbc100 requested a review from kripken September 9, 2024 23:29
Copy link
Collaborator Author

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the test to avoid the sleep. PTAL

@@ -188,7 +188,7 @@ var LibraryPThread = {
// worker pool as an unused worker.
worker.pthread_ptr = 0;

#if ENVIRONMENT_MAY_BE_NODE && PROXY_TO_PTHREAD
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify why this change is necessary? AFAIK, all threads should already be weakly referenced by this point, this should only be required for the "main" thread in PROXY_TO_PTHREAD mode, see:
#19073 (comment)

test/other/test_pthread_strict.c Outdated Show resolved Hide resolved
test/other/test_pthread_strict.c Outdated Show resolved Hide resolved
@sbc100 sbc100 force-pushed the noExitRuntime branch 2 times, most recently from 63d5d7a to 5f573a9 Compare September 11, 2024 21:16
…me is not referenced

Essentially the `keepRuntimeAlive` was relying on the `noExitRuntime`
variable being set based on `EXIT_RUNTIME` but when `noExitRuntime` was
absent the `EXIT_RUNTIME` settings was being ignored and the runtime was
exiting even though `EXIT_RUNTIME=0` was set (the default).

Fixes: emscripten-core#20636
int keep_alive = EM_ASM_INT({
setTimeout(timeout_func);
return keepRuntimeAlive();
}, emscripten_force_exit);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a parameter passed in here?

// EXIT_RUNTIME=0).

EM_JS(void, timeout_func, (), {
console.log("timeout_func: keepRuntimeAlive() ->", keepRuntimeAlive());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you not need to ensure that keepRuntimeAlive is available in JS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

INCOMING_MODULE_JS_API+Pthread+Modularize don't work
3 participants