Skip to content

Conversation

@mhdawson
Copy link
Member

@mhdawsonmhdawson commented Nov 19, 2018

Crashes were reported during finalization due to
the memory for a reference being deleted and the
finalizer running after the deletion.

This change ensures the deletion of the memory for
the reference only occurs after the finalizer has run.

Fixes: nodejs/node-addon-api#393

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

@nodejs-github-bot
Copy link
Collaborator

@mhdawson sadly an error occured when I tried to trigger a build :(

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. node-api Issues and PRs related to the Node-API. labels Nov 19, 2018
@mhdawson
Copy link
MemberAuthor

@hashseed would be good to get somebody from the V8 team to comment on the issue as well since it new gc behaviour seems to be the trigger for us finding the issue.

@gabrielschulhof I know you had run into some issues that resulted in the original code to handle the Reference being deleted in the callback. Would be good to get your review as well.

@addaleax
Copy link
Member

This looks like it already needs a rebase? Plus, it might be nice to have a test for this or so…

@mhdawson
Copy link
MemberAuthor

Rebasing as we speak...

@mhdawson
Copy link
MemberAuthor

Rebased. Was planning to look at a test but I likely won't get to that later in the week.

@sam-github
Copy link
Contributor

@mhdawson commit message has deletion misspelled as "deleteion"

Crashes were reported during finalization due to the memory for a reference being deleted and the finalizer running after the deletion. This change ensures the deletion of the memory for the reference only occurs after the finalizer has run. Fixes: nodejs/node-addon-api#393
@mhdawson
Copy link
MemberAuthor

@sam-github, thanks fixed.

@gabrielschulhof
Copy link
Contributor

@mhdawson from testing locally your change also fixes #23999.

@mhdawson
Copy link
MemberAuthor

@gabrielschulhof that might help me with the test :)

@mhdawson
Copy link
MemberAuthor

Ok, test added. Validated that the test fails consistently without the fix and passes with it :) @addaleax should be good to go now.

@mhdawson
Copy link
MemberAuthor

@mhdawson
Copy link
MemberAuthor

mhdawson commented Nov 22, 2018

and thanks to @toddwong for the basis of the test. I'm surprised it was straightforward to have a test that recreates relatively easily and that runs in a short time period.

@mhdawson
Copy link
MemberAuthor

CI run was good, will plan to land tomorrow unless there are any additional comments/objections.

@refack
Copy link
Contributor

@mhdawson I'm assuming you didn't mean to close this?

@refackrefack reopened this Nov 23, 2018
@addaleaxaddaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Nov 23, 2018
@toddwong
Copy link
Contributor

@mhdawson Ahh! Pleased to know that was helping 😄 And thanks for the fix!

@codebytere
Copy link
Member

@mhdawson could you potentially backport this to v10.x? I've added a label, but feel free to remove it!

refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
Crashes were reported during finalization due to the memory for a reference being deleted and the finalizer running after the deletion. This change ensures the deletion of the memory for the reference only occurs after the finalizer has run. Fixes: nodejs/node-addon-api#393 PR-URL: nodejs#24494 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
@mhdawson
Copy link
MemberAuthor

@codebytere will add to my TODO list.

mhdawson added a commit to mhdawson/io.js that referenced this pull request Jan 18, 2019
Crashes were reported during finalization due to the memory for a reference being deleted and the finalizer running after the deletion. This change ensures the deletion of the memory for the reference only occurs after the finalizer has run. Fixes: nodejs/node-addon-api#393 Backport-PR-URL: nodejs#25572 PR-URL: nodejs#24494 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
@mhdawson
Copy link
MemberAuthor

@codebytere backport PR as requested: #25574

@mhdawson
Copy link
MemberAuthor

@codebytere thanks for reminding me on this one, it is important to get back to 10.x and I should have thought of getting it done earlier.

@mhdawson
Copy link
MemberAuthor

@codebytere PR for backport as requested: #25574

mhdawson added a commit to mhdawson/io.js that referenced this pull request Jan 30, 2019
Crashes were reported during finalization due to the memory for a reference being deleted and the finalizer running after the deletion. This change ensures the deletion of the memory for the reference only occurs after the finalizer has run. Fixes: nodejs/node-addon-api#393 Backport-PR-URL: nodejs#25574 PR-URL: nodejs#24494 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
BethGriggs pushed a commit that referenced this pull request Feb 5, 2019
Crashes were reported during finalization due to the memory for a reference being deleted and the finalizer running after the deletion. This change ensures the deletion of the memory for the reference only occurs after the finalizer has run. Fixes: nodejs/node-addon-api#393 Backport-PR-URL: #25574 PR-URL: #24494 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
@BethGriggsBethGriggs mentioned this pull request Feb 12, 2019
rvagg pushed a commit that referenced this pull request Feb 28, 2019
Crashes were reported during finalization due to the memory for a reference being deleted and the finalizer running after the deletion. This change ensures the deletion of the memory for the reference only occurs after the finalizer has run. Fixes: nodejs/node-addon-api#393 Backport-PR-URL: #25574 PR-URL: #24494 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
@mhdawsonmhdawson mentioned this pull request Apr 4, 2019
2 tasks
mhdawson added a commit to mhdawson/io.js that referenced this pull request Apr 5, 2019
nodejs#24494 fixed a crash but resulted in increased stress on gc finalization. A leak was reported in nodejs#26667 which we are still investigating. As part of this investigation I realized we can optimize to reduce amount of deferred finalization. Regardless of the root cause of the leak this should be a good optimization. It also resolves the leak for the case being reported in nodejs#26667. The OP in 26667 has confirmed that he can still recreate the original problem that 24494 fixed and that the fix still works with this optimization
danbev pushed a commit that referenced this pull request Apr 9, 2019
#24494 fixed a crash but resulted in increased stress on gc finalization. A leak was reported in #26667 which we are still investigating. As part of this investigation I realized we can optimize to reduce amount of deferred finalization. Regardless of the root cause of the leak this should be a good optimization. It also resolves the leak for the case being reported in #26667. The OP in 26667 has confirmed that he can still recreate the original problem that 24494 fixed and that the fix still works with this optimization PR-URL: #27085 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
@mhdawsonmhdawson deleted the finalizer-order2 branch September 30, 2019 13:13
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs 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++.node-apiIssues and PRs related to the Node-API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Signal SIGSEGV in v8::internal::GlobalHandles::Create(v8::internal::Object*) ()

9 participants

@mhdawson@nodejs-github-bot@addaleax@sam-github@gabrielschulhof@refack@toddwong@codebytere@fhinkel