Skip to content

Commit e9a685b

Browse files
legendecasrichardlau
authored andcommitted
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. PR-URL: #59632 Refs: #59550 Reviewed-By: Joyee Cheung <[email protected]>
1 parent 0c2b6df commit e9a685b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/api/environment.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include <cstdlib>
2+
#if HAVE_OPENSSL
3+
#include "crypto/crypto_util.h"
4+
#endif // HAVE_OPENSSL
25
#include "env_properties.h"
36
#include "node.h"
47
#include "node_builtins.h"
@@ -1014,6 +1017,11 @@ void DefaultProcessExitHandlerInternal(Environment* env, ExitCode exit_code) {
10141017
// in node_v8_platform-inl.h
10151018
uv_library_shutdown();
10161019
DisposePlatform();
1020+
1021+
#if HAVE_OPENSSL
1022+
crypto::CleanupCachedRootCertificates();
1023+
#endif // HAVE_OPENSSL
1024+
10171025
Exit(exit_code);
10181026
}
10191027

0 commit comments

Comments
 (0)