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

No call to SetIdle() when terminating #45422

Closed
wants to merge 5 commits into from

Conversation

ywave620
Copy link
Contributor

@ywave620 ywave620 commented Nov 11, 2022

Fix #45421, where you can find a helpful stack trace

One can argues that v8 is responsable for transfering vm state to EXTERNAL before invoking PerIsolateMessageListener(), if v8 agrees and changes for it, this issue is gone without any change of Node.js. However, SetIdle() is basically for cpu profiling only, it's not necessary when terminating. Removing it is not harmful while otherwise will lead to crash before v8 makes that change.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Nov 11, 2022
@ywave620 ywave620 changed the title No set idle when terminating No call to SetIdle() when terminating Nov 11, 2022
Calling SetIdle() when terminating is not harmless.
When node terminates due to an unhandled exception,
v8 preseves the vm state, which is JS and notifies
node through PerIsolateMessageListener(). If node
calls SetIdle() later, v8 complains because it
requires the vm state to either be EXTERNEL or IDLE
when embedder calling SetIdle().
@ywave620
Copy link
Contributor Author

Welcome to join discussion about v8's behavior in https://bugs.chromium.org/p/v8/issues/detail?id=13464

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

LGTM with the caveat that this may end up swapping one bug for another, although it's probably a hypothetical scenario.

I'm thinking of when someone calls isolate->TerminateExecution(), then later on calls isolate->CancelTerminateExecution().

Fix typo

Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
@bnoordhuis bnoordhuis added request-ci Add this label to start a Jenkins CI on a PR. and removed needs-ci PRs that need a full CI run. labels Nov 15, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 15, 2022
@nodejs-github-bot
Copy link
Collaborator

use fixture function to check no abort
@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 16, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 16, 2022
@nodejs-github-bot
Copy link
Collaborator

@ywave620
Copy link
Contributor Author

Sry, the previous commits forgets to wrap an asserttion around common.nodeProcessAborted. Fixed in the latest one. Please rerun the CI.

@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 16, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 16, 2022
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

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

I think the changes here make sense with or without a fix in V8 to update the state to EXTERNAL before invoking the message listener (I think that should also be done - SetIdle() might not be the only victim of it)

Copy link
Member

@santigimeno santigimeno left a comment

Choose a reason for hiding this comment

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

LGTM. By the way, this will fix #41107

@nodejs-github-bot
Copy link
Collaborator

@ywave620
Copy link
Contributor Author

I have moved this change to #45596, which includes a fix to another bug about terminating. PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash if unhandled exception is thrown inside a node program with worker_threads inuse
8 participants