Skip to content

Commit 3747069

Browse files
committed
src: fix race on process exit and off thread CA loading
When calling `process.exit()` or on uncaught exceptions as soon as the process starts, the process will try to terminate immediately. In this case, there could be a race condition on the unfinished off-thread system CA loader which tries to access the OpenSSL API which has been de-inited on the main thread.
1 parent 886e4b3 commit 3747069

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/api/environment.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <cstdlib>
2+
#include "crypto/crypto_util.h"
23
#include "env_properties.h"
34
#include "node.h"
45
#include "node_builtins.h"
@@ -1004,6 +1005,11 @@ void DefaultProcessExitHandlerInternal(Environment* env, ExitCode exit_code) {
10041005
// in node_v8_platform-inl.h
10051006
uv_library_shutdown();
10061007
DisposePlatform();
1008+
1009+
#if HAVE_OPENSSL
1010+
crypto::CleanupCachedRootCertificates();
1011+
#endif // HAVE_OPENSSL
1012+
10071013
Exit(exit_code);
10081014
}
10091015

0 commit comments

Comments
 (0)