-
Notifications
You must be signed in to change notification settings - Fork 28.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
worker: fix nullptr deref after MessagePort deser failure
This would previously always have crashed when deserializing a `MessagePort` fails, because there was always at least one `nullptr` entry in the vector. PR-URL: #25076 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
- Loading branch information
1 parent
1f45b23
commit 4f28da8
Showing
2 changed files
with
20 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/parallel/test-worker-messageport-transfer-terminate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Flags: --experimental-worker | ||
'use strict'; | ||
require('../common'); | ||
const { Worker, MessageChannel } = require('worker_threads'); | ||
|
||
// Check the interaction of calling .terminate() while transferring | ||
// MessagePort objects; in particular, that it does not crash the process. | ||
|
||
for (let i = 0; i < 10; ++i) { | ||
const w = new Worker( | ||
"require('worker_threads').parentPort.on('message', () => {})", | ||
{ eval: true }); | ||
setImmediate(() => { | ||
const port = new MessageChannel().port1; | ||
w.postMessage({ port }, [ port ]); | ||
w.terminate(); | ||
}); | ||
} |