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

timers: check can_call_into_js in Immediates #21057

Closed

Conversation

apapirovski
Copy link
Member

@apapirovski apapirovski commented May 31, 2018

Do not call into JS if it's not safe in Immediates and prevent a future infinite loop.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Do not execute native immediates and prevent infinite loop if it's
possible to call into JS
@apapirovski apapirovski added c++ Issues and PRs that require attention from people who are familiar with C++. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout. labels May 31, 2018
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label May 31, 2018
src/env.cc Outdated
@@ -457,7 +457,7 @@ void Environment::RunAndClearNativeImmediates() {
void Environment::CheckImmediate(uv_check_t* handle) {
Environment* env = Environment::from_immediate_check_handle(handle);

if (env->immediate_info()->count() == 0)
if (env->immediate_info()->count() == 0 || !env->can_call_into_js())
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be right before the do {, because we probably want our native immediate callbacks to still be called – not all of them are calling JS, some or doing cleanup rather than something else

Copy link
Member Author

Choose a reason for hiding this comment

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

Would that be strictly correct even if it's not calling JS? At least in relation to the main thread (and not workers), the expectation was that no user code would run after EmitExit finishes. After RunCleanup was added that's no longer the case since we run the loop one final time.

Are there are any Immediates that we truly want to have run at this point?

@apapirovski
Copy link
Member Author

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 1, 2018
@apapirovski
Copy link
Member Author

Landed in 5a6b197

@apapirovski apapirovski closed this Jun 4, 2018
@apapirovski apapirovski deleted the patch-skip-immediates-on-exit branch June 4, 2018 07:22
apapirovski added a commit that referenced this pull request Jun 4, 2018
Prevent an infinite loop if it's not possible to call into JS.

PR-URL: #21057
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
MylesBorins pushed a commit that referenced this pull request Jun 6, 2018
Prevent an infinite loop if it's not possible to call into JS.

PR-URL: #21057
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
@MylesBorins MylesBorins mentioned this pull request Jun 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. timers Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants