Unverified Commit 65a7fd3e authored by Michael Dawson's avatar Michael Dawson Committed by Michaël Zasso
Browse files

node-api: avoid SecondPassCallback crash

PR https://github.com/nodejs/node/pull/38000 added
indirection so that we could stop finalization in
cases where it had been scheduled in a second
pass callback but we were doing it in advance in
environment teardown.

Unforunately we missed that the code which tries
to clear the second pass parameter checked if
the pointer to the parameter (_secondPassParameter)
was nullptr and that when the second pass callback
was scheduled we set _secondPassParameter to nullptr
in order to avoid it being deleted outside of the second
pass callback. The net result was that we
would not clear the _secondPassParameter contents
and failed to avoid the Finalization in the second pass
callback.

This PR adds an additional boolean for deciding if
the secondPassParameter should be deleted outside
of the second pass callback instead of setting
secondPassParameter to nullptr thus avoiding the
conflict between the 2 ways it was being used.

See the discussion starting at:
https://github.com/nodejs/node/pull/38273#issuecomment-852403751


for how this was discovered on OSX while trying to
upgrade to a new V8 version.

Signed-off-by: default avatarMichael Dawson <mdawson@devrus.com>

PR-URL: https://github.com/nodejs/node/pull/38899


Reviewed-By: default avatarChengzhong Wu <legendecas@gmail.com>
Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
parent 07339eca
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment