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

src: add handle scope to OnFatalError() #25775

Closed

Conversation

addaleax
Copy link
Member

For the report generation, we use Environment::GetCurrent(isolate)
which uses isolate->GetCurrentContext() under the hood, thus
allocates a handle. Without a HandleScope, this is invalid.

This might not strictly be allowed inside of OnFatalError(),
but it won’t make anything worse either.

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

For the report generation, we use `Environment::GetCurrent(isolate)`
which uses `isolate->GetCurrentContext()` under the hood, thus
allocates a handle. Without a `HandleScope`, this is invalid.

This might not strictly be allowed inside of `OnFatalError()`,
but it won’t make anything worse either.
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jan 28, 2019
@addaleax addaleax added the report Issues and PRs related to process.report. label Jan 28, 2019
Copy link
Member

@gireeshpunathil gireeshpunathil left a comment

Choose a reason for hiding this comment

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

@addaleax: 2 questions:

Without a HandleScope, this is invalid.

does that mean any caller of Environment::GetCurrent(isolate) create a handlescope in its frame? I thought that is required only if one is dealing with JS objects. I am not seeing this as followed anywhere else?

but it won’t make anything worse either.

do you think under extreme situations creation of HandleScope itself can lead to cascaded failures?

@addaleax
Copy link
Member Author

Without a HandleScope, this is invalid.

does that mean any caller of Environment::GetCurrent(isolate) create a handlescope in its frame?

Yes.

I thought that is required only if one is dealing with JS objects.

isolate->GetCurrentContext() does allocate a handle, even if it’s not for a JS object – to V8 it’s all the same.

I am not seeing this as followed anywhere else?

We do always have a handle scope – there’s just usually already another one present.

but it won’t make anything worse either.

do you think under extreme situations creation of HandleScope itself can lead to cascaded failures?

I would assume that that’s the case for when e.g. creating a HandleScope fails and triggers the fatal error handler, yes.

@addaleax
Copy link
Member Author

addaleax commented Jan 29, 2019

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 29, 2019
@addaleax
Copy link
Member Author

Landed in 006aa63

@addaleax addaleax closed this Jan 30, 2019
@addaleax addaleax deleted the report-fatal-error-handle-scope branch January 30, 2019 22:46
addaleax added a commit that referenced this pull request Jan 30, 2019
For the report generation, we use `Environment::GetCurrent(isolate)`
which uses `isolate->GetCurrentContext()` under the hood, thus
allocates a handle. Without a `HandleScope`, this is invalid.

This might not strictly be allowed inside of `OnFatalError()`,
but it won’t make anything worse either.

PR-URL: #25775
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax added a commit that referenced this pull request Jan 30, 2019
For the report generation, we use `Environment::GetCurrent(isolate)`
which uses `isolate->GetCurrentContext()` under the hood, thus
allocates a handle. Without a `HandleScope`, this is invalid.

This might not strictly be allowed inside of `OnFatalError()`,
but it won’t make anything worse either.

PR-URL: #25775
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@targos targos mentioned this pull request Feb 14, 2019
addaleax added a commit to addaleax/node that referenced this pull request Mar 1, 2019
Do not require an explicit `HandleScope`, or the ability to create
one, when using `Environment::GetCurrent()`.

`isolate->InContext()` is used as an indicator that it is probably
okay to create a `HandleScope`, see also the short discussion in
nodejs#25775 (review).
addaleax added a commit that referenced this pull request Mar 5, 2019
Do not require an explicit `HandleScope`, or the ability to create
one, when using `Environment::GetCurrent()`.

`isolate->InContext()` is used as an indicator that it is probably
okay to create a `HandleScope`, see also the short discussion in
#25775 (review).

PR-URL: #26376
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Mar 12, 2019
Do not require an explicit `HandleScope`, or the ability to create
one, when using `Environment::GetCurrent()`.

`isolate->InContext()` is used as an indicator that it is probably
okay to create a `HandleScope`, see also the short discussion in
nodejs#25775 (review).

PR-URL: nodejs#26376
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
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++. report Issues and PRs related to process.report.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants