mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
448d5d1a19
Worker.parent_port_ can be released before the exit event of Worker. The parent_port_ is not owned by `node::worker::Worker`, thus the reference to it is not always valid, and accessing it at exit crashes the process. As the Worker.parent_port_ is only used in the memory info tracking, it can be safely removed. PR-URL: https://github.com/nodejs/node/pull/43123 Fixes: https://github.com/nodejs/node/issues/43122 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
18 lines
548 B
JavaScript
18 lines
548 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { getHeapSnapshot } = require('v8');
|
|
const { isMainThread, Worker } = require('worker_threads');
|
|
|
|
// Checks taking heap snapshot at the exit event listener of Worker doesn't
|
|
// crash the process.
|
|
// Regression for https://github.com/nodejs/node/issues/43122.
|
|
if (isMainThread) {
|
|
const worker = new Worker(__filename);
|
|
|
|
worker.once('exit', common.mustCall((code) => {
|
|
assert.strictEqual(code, 0);
|
|
getHeapSnapshot().pipe(process.stdout);
|
|
}));
|
|
}
|