You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this is v8/v8@b6b7de0 … since there are no accompanying API changes in V8, I think code that worked before should also work after, so this might be a bug in V8? I’ll still try to figure out what’s happening here exactly, but I think there might be a chance that V8 is trying to free an externalized SharedArrayBuffer instance on Isolate teardown.
Hm yeah, I’m a bit stumped. The V8 change requires the ArrayBuffer::Allocator behind a SharedArrayBuffer to have a longer lifetime than previously, and while the change is one in the right direction, the different timing means that V8 tries to access it after we destroyed it.
So … what we could do, I think, is to store all ArrayBuffer::Allocator instances referenced by a Node.js Environment in a separate array that outlives the Environment, and then release those after the Isolate has been torn down – this isn’t a good solution, though, and one that requires a breaking change to our embedder API, at least temporarily (if we want to avoid memory leaks).
@targos What Node.js release lines would the V8 change affect? Is it something that would align with a semver-major release on our side?
This change won't land on time for Node.js 13.0.0.
There are at least two options:
We make the necessary breaking API changes before 13.0.0, allowing us to upgrade V8 in a semver-minor when the version containing this change is released.
We wait for the integration of this change in Node.js to adapt our API, locking us to the previous V8 version until Node.js 14.0.0 is released.
Is this still an issue? I ask, because I've updated to backing store in Node 14 to solve the deprecation warnings; everything's kind of working, but the backing store is created... in not the main thread... and is being released in not the main thread; and is crashing in the deconstructor method of BackingStore...
No, in 14, windows debug addons crash with release Node... have to build a debug node to use debug plugins, otherwise the arraybuffer delete uses the wrong runtime (uses the delete linked with the addon, and not the delete linked with node that created the object in the first place)
Edit:err, sorry, I guess 'this' doesn't fail... just backing stores.
Activity
targos commentedon Sep 11, 2019
Backtrace with debug build:
targos commentedon Sep 11, 2019
The line that fails: https://github.com/nodejs/node/blob/ebfb709b5f095c43f528affaaafe027efe6c223d/deps/v8/src/objects/backing-store.cc#L157
addaleax commentedon Sep 11, 2019
Thanks for the ping, I’ll look into it
addaleax commentedon Sep 12, 2019
I think this is v8/v8@b6b7de0 … since there are no accompanying API changes in V8, I think code that worked before should also work after, so this might be a bug in V8? I’ll still try to figure out what’s happening here exactly, but I think there might be a chance that V8 is trying to free an externalized SharedArrayBuffer instance on Isolate teardown.
Is Node.js still part of the V8 CI? https://github.com/v8/node/ doesn’t seem up to date at all… /cc @hashseed @titzer
targos commentedon Sep 12, 2019
Here is the node V8 CI run for that commit: https://ci.chromium.org/p/node-ci/builders/try/node_ci_linux64_rel/b8906314882042544400
It is green but I don't see this test in the output.
targos commentedon Sep 12, 2019
Of course, you added the test less than a month ago, so without an up to date v8/node repo it won't be executed by the V8 CI
addaleax commentedon Sep 12, 2019
Yes, this is it. It might be possible to work around this in Node.js, but the new semantics aren’t really clear to me at a glance.
addaleax commentedon Sep 13, 2019
Hm yeah, I’m a bit stumped. The V8 change requires the
ArrayBuffer::Allocatorbehind aSharedArrayBufferto have a longer lifetime than previously, and while the change is one in the right direction, the different timing means that V8 tries to access it after we destroyed it.addaleax commentedon Sep 13, 2019
So … what we could do, I think, is to store all
ArrayBuffer::Allocatorinstances referenced by a Node.jsEnvironmentin a separate array that outlives theEnvironment, and then release those after theIsolatehas been torn down – this isn’t a good solution, though, and one that requires a breaking change to our embedder API, at least temporarily (if we want to avoid memory leaks).@targos What Node.js release lines would the V8 change affect? Is it something that would align with a semver-major release on our side?
targos commentedon Sep 13, 2019
This change won't land on time for Node.js 13.0.0.
There are at least two options:
worker: keep allocators for transferred SAB instances alive longer
addaleax commentedon Sep 20, 2019
@targos Sometimes it’s good to get a bit of distance and think about it again :) Found a way to address this without API changes: nodejs/node#29637
worker: keep allocators for transferred SAB instances alive longer
test: expand Worker test for non-shared ArrayBuffer
8 remaining items
deps: V8: cherry-pick 6b0a953
test: expand Worker test for non-shared ArrayBuffer
deps: V8: cherry-pick 6b0a953
test: expand Worker test for non-shared ArrayBuffer
test: expand Worker test for non-shared ArrayBuffer
deps: V8: cherry-pick 6b0a953
deps: V8: cherry-pick 6b0a953
d3x0r commentedon Jun 8, 2020
Is this still an issue? I ask, because I've updated to backing store in Node 14 to solve the deprecation warnings; everything's kind of working, but the backing store is created... in not the main thread... and is being released in not the main thread; and is crashing in the deconstructor method of BackingStore...
JingkunHu commentedon Oct 2, 2020
Segmentation fault still happens when running node 12.18.4 with multi-worker-threads
Trott commentedon Oct 3, 2020
I don't believe this was fixed in 12.x. Fixed in 14.0.0 though.
d3x0r commentedon Oct 4, 2020
No, in 14, windows debug addons crash with release Node... have to build a debug node to use debug plugins, otherwise the arraybuffer delete uses the wrong runtime (uses the delete linked with the addon, and not the delete linked with node that created the object in the first place)
Edit:err, sorry, I guess 'this' doesn't fail... just backing stores.
worker: keep allocators for transferred SAB instances alive longer