GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — n-api: back up env before async work finalize by gabrielschulhof · Pull Request #21129 · nodejs/node

Conversation

@gabrielschulhof

@gabrielschulhof gabrielschulhof commented Jun 4, 2018

Copy link
Copy Markdown
Contributor

We must back up the value of _env before calling the async work
complete callback, because the complete callback may delete the
instance in which _env is stored by calling napi_delete_async_work,
and because we need to use it after the complete callback has
completed.

Fixes: #20966

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. dont-land-on-v4.x node-api Issues and PRs related to Node-API. labels Jun 4, 2018
@gabrielschulhof

gabrielschulhof commented Jun 4, 2018

Copy link
Copy Markdown
Contributor Author

I'm not sure if it makes any sense to add a test like this one, but finite.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof
gabrielschulhof requested a review from addaleax June 4, 2018 23:42
@nstepien

nstepien commented Jun 4, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Considering this fixes a regression, I'd say a test should be added.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof

gabrielschulhof commented Jun 4, 2018

Copy link
Copy Markdown
Contributor Author

@MayhemYDG the problem is it's a memory corruption regression, so a 100% reliable test is hard to create. After all, when c072057 introduced the regression, the async work test which we already have should have segfaulted but didn't.

My only thought with the above comment was to add a second test which essentially runs the first test over and over and over, because that's what I used for reproducing. But you're right - I think I'll add a test like the one in the gist, with, say, 500 iterations. Hopefully in that many iterations it will crash if we ever again have such a bug.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof
gabrielschulhof force-pushed the napi-delete-async-work branch from 18a98d9 to 2853b40 Compare June 5, 2018 14:28
@gabrielschulhof

gabrielschulhof commented Jun 5, 2018

Copy link
Copy Markdown
Contributor Author

Well, the test I added crashes before the fix and passes after the fix, so FWIW, it captures the fix.

nstepien reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mhdawson
mhdawson approved these changes Jun 5, 2018
View reviewed changes

@mhdawson mhdawson left a comment

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mhdawson
mhdawson approved these changes Jun 5, 2018
View reviewed changes

@mhdawson mhdawson left a comment

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gabrielschulhof

gabrielschulhof commented Jun 5, 2018

Copy link
Copy Markdown
Contributor Author

CI: https://ci.nodejs.org/job/node-test-pull-request/15264/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof
gabrielschulhof force-pushed the napi-delete-async-work branch from 2853b40 to a3b4c9e Compare June 5, 2018 21:26
@gabrielschulhof

gabrielschulhof commented Jun 5, 2018

Copy link
Copy Markdown
Contributor Author

Another CI: https://ci.nodejs.org/job/node-test-pull-request/15268/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Gabriel Schulhof
n-api: back up env before async work finalize
c7b1950
We must back up the value of `_env` before calling the async work
complete callback, because the complete callback may delete the
instance in which `_env` is stored by calling `napi_delete_async_work`,
and because we need to use it after the complete callback has
completed.

Fixes: nodejs#20966
@gabrielschulhof
gabrielschulhof force-pushed the napi-delete-async-work branch from a3b4c9e to c7b1950 Compare June 6, 2018 01:23
@gabrielschulhof

gabrielschulhof commented Jun 6, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

sigh ... forgot to set the name of the async context - weird that it did not throw in debug mode O_o

Here's another CI: https://ci.nodejs.org/job/node-test-pull-request/15273/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

apapirovski
apapirovski approved these changes Jun 6, 2018
View reviewed changes
@nstepien

nstepien commented Jun 6, 2018

Copy link
Copy Markdown
Contributor

@gabrielschulhof
Nice. Do you think this could get merged in time for the v10.4.0 release?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

refack
refack approved these changes Jun 6, 2018
View reviewed changes
@gabrielschulhof gabrielschulhof mentioned this pull request Jun 6, 2018
v10.4.0 proposal #21167
Merged
@refack

refack commented Jun 6, 2018

Copy link
Copy Markdown
Contributor

I'm +1 to land this after only 40h so it make it into 10.4.0, since the most significant stakeholders are aware of this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof

gabrielschulhof commented Jun 6, 2018

Copy link
Copy Markdown
Contributor Author

@refack OK, landing it then.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gabrielschulhof pushed a commit that referenced this pull request Jun 6, 2018
Gabriel Schulhof
n-api: back up env before async work finalize
991f406
We must back up the value of `_env` before calling the async work
complete callback, because the complete callback may delete the
instance in which `_env` is stored by calling `napi_delete_async_work`,
and because we need to use it after the complete callback has
completed.

Fixes: #20966
PR-URL: #21129
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@MylesBorins

MylesBorins commented Jun 6, 2018

Copy link
Copy Markdown
Contributor

landed in 991f406

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MylesBorins MylesBorins closed this Jun 6, 2018
@gabrielschulhof
gabrielschulhof deleted the napi-delete-async-work branch June 6, 2018 17:32
targos pushed a commit that referenced this pull request Jun 7, 2018
Gabriel Schulhof @targos
n-api: back up env before async work finalize
917615e
We must back up the value of `_env` before calling the async work
complete callback, because the complete callback may delete the
instance in which `_env` is stored by calling `napi_delete_async_work`,
and because we need to use it after the complete callback has
completed.

Fixes: #20966
PR-URL: #21129
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@mhdawson mhdawson mentioned this pull request Jul 4, 2018
v8.12.0 proposal #21593
Merged
@MylesBorins MylesBorins added the backport-requested-v8.x label Jul 9, 2018
@MylesBorins

MylesBorins commented Jul 9, 2018

Copy link
Copy Markdown
Contributor

Should this be backported to v8.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof

gabrielschulhof commented Jul 10, 2018

Copy link
Copy Markdown
Contributor Author

@MylesBorins this actually fixes a regression introduced by c072057, so, unless we backport that commit too, we need not backport this commit. As it stands, it doesn't look like that commit was backported to v8.x.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gabrielschulhof gabrielschulhof removed the backport-requested-v8.x label Jul 10, 2018
firass111 pushed a commit to firass111/Project_node1 that referenced this pull request Apr 16, 2025
Gabriel Schulhof @evanlucas
n-api: back up env before async work finalize
53f8563
We must back up the value of `_env` before calling the async work
complete callback, because the complete callback may delete the
instance in which `_env` is stored by calling `napi_delete_async_work`,
and because we need to use it after the complete callback has
completed.

Fixes: nodejs/node#20966
PR-URL: nodejs/node#21129
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@addaleax addaleax Awaiting requested review from addaleax
3 more reviewers
@apapirovski apapirovski apapirovski approved these changes
@refack refack refack approved these changes
@mhdawson mhdawson mhdawson approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. node-api Issues and PRs related to Node-API.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

n-api: regression with napi_delete_async_work since v10.2.0

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@gabrielschulhof @nstepien @refack @MylesBorins @apapirovski @mhdawson @nodejs-github-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.