-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
src: handle fatal error when Environment is not assigned to context #27236
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously when a uncaught JS error is thrown before Environment was assigned to the context (e.g. a SyntaxError in a per-context script), it triggered an infinite recursion: 1. The error message listener `node::OnMessage()` triggered `node::FatalException()` 2. `node::FatalException()` attempted to get the Environment assigned to the context entered using `Environment::GetCurrent()` 3. `Environment::GetCurrent()` previously incorrectly accepted out-of-bound access with the length of the embedder data array as index, and called `context->GetAlignedPointerFromEmbedderData()` 4. The out-of-bound access in `GetAlignedPointerFromEmbedderData()` triggered a fatal error, which was handled by `node::FatalError()` 5. `node::FatalError()` calls `node::FatalException()`, then we enter the infinite recursion. This patch fixes the incorrect guard in 3, and handles error with best-effort when `Environment::GetCurrent()` returns nullptr (when Environment is not yet assigned to the context) in 2.
nodejs-github-bot
added
the
c++
Issues and PRs that require attention from people who are familiar with C++.
label
Apr 15, 2019
joyeecheung
commented
Apr 15, 2019
bnoordhuis
approved these changes
Apr 15, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some comments/questions.
jasnell
approved these changes
Apr 15, 2019
jasnell
approved these changes
Apr 15, 2019
jasnell
approved these changes
Apr 15, 2019
addaleax
approved these changes
Apr 15, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
addaleax
added
the
author ready
PRs that have at least one approval, no pending requests for changes, and a CI started.
label
Apr 15, 2019
bnoordhuis
approved these changes
Apr 16, 2019
Landed in cdba9f2 with the comment nit fixed. |
joyeecheung
added a commit
that referenced
this pull request
Apr 17, 2019
Previously when an uncaught JS error is thrown before Environment was assigned to the context (e.g. a SyntaxError in a per-context script), it triggered an infinite recursion: 1. The error message listener `node::OnMessage()` triggered `node::FatalException()` 2. `node::FatalException()` attempted to get the Environment assigned to the context entered using `Environment::GetCurrent()` 3. `Environment::GetCurrent()` previously incorrectly accepted out-of-bound access with the length of the embedder data array as index, and called `context->GetAlignedPointerFromEmbedderData()` 4. The out-of-bound access in `GetAlignedPointerFromEmbedderData()` triggered a fatal error, which was handled by `node::FatalError()` 5. `node::FatalError()` called `Environment::GetCurrent()`, then we went back to 3. This patch fixes the incorrect guard in 3. When `Environment::GetCurrent()` returns nullptr (when Environment is not yet assigned to the context) in 2, it now prints the JS stack trace and crashes directly. PR-URL: #27236 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This was referenced Apr 20, 2019
This was referenced Apr 23, 2019
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++.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously when an uncaught JS error is thrown before Environment was
assigned to the context (e.g. a SyntaxError in a per-context script),
it triggered an infinite recursion:
node::OnMessage()
triggerednode::FatalException()
node::FatalException()
attempted to get the Environmentassigned to the context entered using
Environment::GetCurrent()
Environment::GetCurrent()
previously incorrectly acceptedout-of-bound access with the length of the embedder data array
as index, and called
context->GetAlignedPointerFromEmbedderData()
GetAlignedPointerFromEmbedderData()
triggered a fatal error, which was handled by
node::FatalError()
node::FatalError()
calledEnvironment::GetCurrent()
, thenwe went back to 3.
This patch fixes the incorrect guard in 3. When
Environment::GetCurrent()
returns nullptr (when Environment is not yet assigned to the context) in 2,
it now prints the JS stack trace and crashes directly.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes