Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ void DefaultProcessExitHandler(Environment* env, int exit_code) {
env->set_can_call_into_js(false);
env->stop_sub_worker_contexts();
DisposePlatform();
uv_library_shutdown();
exit(exit_code);
}

Expand Down
28 changes: 28 additions & 0 deletions test/parallel/test-crypto-op-during-process-exit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto) { common.skip('missing crypto'); }
const assert = require('assert');
const { generateKeyPair } = require('crypto');

if (common.isWindows) {
// Remove this conditional once the libuv change is in Node.js.
common.skip('crashing due to https://github.com/libuv/libuv/pull/2983');
}

// Regression test for a race condition: process.exit() might lead to OpenSSL
// cleaning up state from the exit() call via calling its destructor, but
// running OpenSSL operations on another thread might lead to them attempting
// to initialize OpenSSL, leading to a crash.
// This test crashed consistently on x64 Linux on Node v14.9.0.

generateKeyPair('rsa', {
modulusLength: 2048,
privateKeyEncoding: {
type: 'pkcs1',
format: 'pem'
}
}, (err/* , publicKey, privateKey */) => {
assert.ifError(err);
});

setTimeout(() => process.exit(), common.platformTimeout(10));