| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
This will likely break process.cwd() after changing the directory as it will return a cached value.
cwd() should also be protected in that case:
node/lib/internal/main/worker_thread.js
Lines 138 to 152 in 82b1b55
I am fine doing that, I just wonder if this is a common situation at all. AFAIK we mostly do not check all possible configurations and do not officially support them?
If we want to support the flag, we should also add a test (while such test can't really protect from other potential SharedArrayBuffer usages).
Sorry, something went wrong.
|
@BridgeAR happy to add a test - the other reason i'm interested in this in particular is because it's disabled in the web (see here) unless cross origin isolation is enabled, so this crashes the renderer process in some cases in Electron as well. |
Sorry, something went wrong.
|
Is it repl or worker (the subsystem)? |
Sorry, something went wrong.
|
@targos i guess sort of both? I can make it whatever you think would be preferable, but it'd be hit anytime anyone invoked repl.start() or when dealing with cwd in workers. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM with lint fix and either a test or a comment (or both).
Sorry, something went wrong.
@codebytere repl,worker: fix crash ... would work :) |
Sorry, something went wrong.
|
@BridgeAR i think that should do it - let me know if you had something else in mind tho! |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM. Just left a comment how the test could be improved.
Sorry, something went wrong.
Sorry, something went wrong.
|
There's a relevant failure in CI. The test added here fails when invoked with test/tools.py --worker. |
Sorry, something went wrong.
|
@Trott are you potentially able to replicate locally? i'm seeing node on git:fix-sab-crash ❯ tools/test.py --worker test/parallel/test-worker-no-sab === release test-worker-no-sab === Path: parallel/test-worker-no-sab Command: out/Release/node --no-harmony-sharedarraybuffer /Users/codebytere/Developer/node/tools/run-worker.js /Users/codebytere/Developer/node/test/parallel/test-worker-no-sab.js [00:00|% 100|+ 0|- 1]: Done passing when i run locally 🤔 |
Sorry, something went wrong.
Sorry, something went wrong.
@codebytere That's not passing. The 1 would be in the + cell if it was passing, and the 0 would b e in the - cell. (You can see the difference if you run it again without --worker. Or you can try running it with --worker but run ttest/parallel/test-worker-no-s* to see one test pass and one test fail.) The lack of output, though, is odd.... |
Sorry, something went wrong.
The lack of output is legit. (Maybe we should update tools/run-worker.js to provide output in this situation?) To replicate without the Python script, run this out/Release/node --no-harmony-sharedarraybuffer /Users/trott/io.js/tools/run-worker.js /Users/trott/io.js/test/parallel/test-worker-no-sab.js. It will return no output, but exit with an error code. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM with my comments addressed.
Sorry, something went wrong.
| const { isMainThread, Worker } = require('worker_threads'); | ||
|
|
||
| // Regression test for https://github.com/nodejs/node/issues/39717. | ||
|
|
||
| const w = new Worker(__filename); | ||
|
|
||
| w.on('exit', common.mustCall((status) => { | ||
| assert.strictEqual(status, 2); | ||
| })); | ||
|
|
||
| if (!isMainThread) process.exit(2); |
There was a problem hiding this comment.
| const { isMainThread, Worker } = require('worker_threads'); | |
| // Regression test for https://github.com/nodejs/node/issues/39717. | |
| const w = new Worker(__filename); | |
| w.on('exit', common.mustCall((status) => { | |
| assert.strictEqual(status, 2); | |
| })); | |
| if (!isMainThread) process.exit(2); | |
| const { Worker } = require('worker_threads'); | |
| // Regression test for https://github.com/nodejs/node/issues/39717. | |
| // Do not use isMainThread so that this test itself can be run inside a Worker. | |
| if (!process.env.HAS_STARTED_WORKER) { | |
| process.env.HAS_STARTED_WORKER = 1; | |
| const w = new Worker(__filename); | |
| w.on('exit', common.mustCall((status) => { | |
| assert.strictEqual(status, 2); | |
| })); | |
| } else { | |
| process.exit(2); | |
| } |
Sorry, something went wrong.
There was a problem hiding this comment.
@codebytere Are you ok if we commit this suggestion, run tests, check with @BridgeAR if they can then approve the PR,, and hopefully land? Or is there something about this suggestion that would make you reluctant to do that?
Sorry, something went wrong.
|
|
||
| process.cwd = function() { | ||
| // SharedArrayBuffers can be disabled with --no-harmony-sharedarraybuffer. | ||
| if (typeof SharedArrayBuffer === 'undefined') return originalCwd(); |
There was a problem hiding this comment.
This is fine but we could prevent replacing process.cwd in the first place, so that the extra check is not needed when calling process.cwd().
Sorry, something went wrong.
| function main({ n }) { | ||
| if (typeof SharedArrayBuffer === 'undefined') { | ||
| throw new Error('SharedArrayBuffers must be enabled to run this benchmark'); | ||
| } |
There was a problem hiding this comment.
main is going to be executed more than once. As such, it's probably best to move the check to the top of the file.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes #39717.
It's possible for SharedArrayBuffers to be disabled with --no-harmony-sharedarraybuffer so we first need to check that this isn't the case before attempting to use them in the repl or the following crash occurs:
electron_node on git:a3d0cc7244 ❯ node --no-harmony-sharedarraybuffer 6:25PM Welcome to Node.js v16.2.0. Type ".help" for more information. > snode:internal/readline/emitKeypressEvents:71 throw err; ^ TypeError: SharedArrayBuffer is not a constructor at node:internal/worker:96:32 at NativeModule.compileForInternalLoader (node:internal/bootstrap/loaders:312:7) at nativeModuleRequire (node:internal/bootstrap/loaders:341:14) at node:worker_threads:11:5 at NativeModule.compileForInternalLoader (node:internal/bootstrap/loaders:312:7) at nativeModuleRequire (node:internal/bootstrap/loaders:341:14) at node:inspector:32:26 at NativeModule.compileForInternalLoader (node:internal/bootstrap/loaders:312:7) at nativeModuleRequire (node:internal/bootstrap/loaders:341:14) at sendInspectorCommand (node:internal/util/inspector:14:21)