Uh oh!
There was an error while loading. Please reload this page.
worker: don't use two-arg NewIsolate - #29850
Conversation
fbb66b2 to
e4b8809CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
e4b8809 to
b8bcdc0Compare
jasnell
left a comment
There was a problem hiding this comment.
Generally LGTM with @bnoordhuis comments addressed
addaleax
left a comment
There was a problem hiding this comment.
How is Electron initiating Node.js here? The NewIsolate() and CreateIsolateData() variants that take a MultiIsolatePlatform* argument are kind of supposed to solve this problem, but it seems Electron is doing something else?
If we do land this, I’d like to make it clear from the beginning that this is a temporary hack to support Electron, and maybe deprecate it immediately.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
codebytere
commented
Oct 5, 2019
@addaleax when |
addaleax
commented
Oct 5, 2019
@codebytere I’m surprised … that code is missing a deallocation corresponding to Is there an Electron bug report corresponding to this/Can you maybe share more info about the crash you’re referring to in the PR description itself (e.g. a reproduction/stack trace)? Otherwise I’m also happy to try and build Electron myself… :) |
addaleax
commented
Oct 5, 2019
@codebytere Maybe for more context, what I’m thinking is that, at least once the Node.js Environment is set up, all attempts to access the underlying platform should use |
I think the thing i'm not quite sure on at the moment is how this might have worked previously - doesn't The crash is just that - it fails here @ L233 with |
addaleax
commented
Oct 6, 2019
@codebytere Yes, but I’d say that As far as I can tell, it is only used in Node.js when running Node.js through |
In |
addaleax
commented
Oct 6, 2019
@codebytere Thanks! I think that’s a clear oversight (and most likely on my part, sorry). Does this help? diff --git a/src/node_worker.cc b/src/node_worker.cc
index 11e44a92757e..3dce5e25980c 100644
--- a/src/node_worker.cc+++ b/src/node_worker.cc@@ -116,7 +116,10 @@ class WorkerThreadData {
: w_(w) {
CHECK_EQ(uv_loop_init(&loop_), 0);
- Isolate* isolate = NewIsolate(w->array_buffer_allocator_.get(), &loop_);+ Isolate* isolate = NewIsolate(+ w->array_buffer_allocator_.get(),+ &loop_,+ w->platform_);
CHECK_NOT_NULL(isolate);
{ |
codebytere
commented
Oct 6, 2019
Ah, awesome! That's a far simpler fix so i'm all for it haha I'll update this PR with that simpler change as soon as i verify :D |
b8bcdc0 to
ea00cacCompare@addaleax updated and verified in Electron ⭐️ Thanks for the assist! |
nodejs-github-bot
commented
Oct 6, 2019
bnoordhuis
commented
Oct 7, 2019
PR-URL: #29850 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Trott
commented
Oct 9, 2019
Landed in 6db45bf |
PR-URL: #29850 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Electron creates and initializes the V8 platform ourselves, and so need to build with
NODE_USE_V8_PLATFORMset tofalseand as a result were unable to useworker_threads.This PR fixes this problem by swapping the two-arg call to NewIsolate present in
NodeWorkerDatafor the three-arg version.Before, the two-arg version calls the three-arg version with
GetMainThreadMultiIsolatePlatform(), which is implemented withper_process::v8_platform.Platform(). That returnsnullptrwhenNODE_USE_V8_PLATFORMset tofalse, and causes a bad access crash.cc @joyeecheung@addaleax
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes