Uh oh!
There was an error while loading. Please reload this page.
n-api: back up env before async work finalize - #21129
Conversation
gabrielschulhof
commented
Jun 4, 2018
I'm not sure if it makes any sense to add a test like this one, but finite. |
Considering this fixes a regression, I'd say a test should be added. |
gabrielschulhof
commented
Jun 4, 2018
@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. |
18a98d9 to
2853b40Comparegabrielschulhof
commented
Jun 5, 2018
Well, the test I added crashes before the fix and passes after the fix, so FWIW, it captures the fix. |
gabrielschulhof
commented
Jun 5, 2018
2853b40 to
a3b4c9eComparegabrielschulhof
commented
Jun 5, 2018
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
a3b4c9e to
c7b1950Comparesigh ... 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/ |
nstepien
commented
Jun 6, 2018
@gabrielschulhof |
refack
commented
Jun 6, 2018
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. |
gabrielschulhof
commented
Jun 6, 2018
@refack OK, landing it then. |
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 <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
MylesBorins
commented
Jun 6, 2018
landed in 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 <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
MylesBorins
commented
Jul 9, 2018
Should this be backported to |
gabrielschulhof
commented
Jul 10, 2018
@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. |
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 <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
We must back up the value of
_envbefore calling the async workcomplete callback, because the complete callback may delete the
instance in which
_envis stored by callingnapi_delete_async_work,and because we need to use it after the complete callback has
completed.
Fixes: #20966
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes