Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5fe7741

Browse filesBrowse files
committed
src: dispose of V8 platform in process.exit()
Calling `process.exit()` calls the C `exit()` function, which in turn calls the destructors of static C++ objects. This can lead to race conditions with other concurrently executing threads; disposing of all Worker threads and then the V8 platform instance helps with this (although it might not be a full solution for all problems of this kind). Refs: #24403 Refs: #25007 PR-URL: #25061 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent b67c4b4 commit 5fe7741
Copy full SHA for 5fe7741

File tree

Expand file treeCollapse file tree

3 files changed

+10
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+10
-2
lines changed
Open diff view settings
Collapse file

‎src/env.cc‎

Copy file name to clipboardExpand all lines: src/env.cc
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,10 +862,13 @@ void Environment::AsyncHooks::grow_async_ids_stack() {
862862
uv_key_t Environment::thread_local_env = {};
863863

864864
void Environment::Exit(int exit_code) {
865-
if (is_main_thread())
865+
if (is_main_thread()) {
866+
stop_sub_worker_contexts();
867+
DisposePlatform();
866868
exit(exit_code);
867-
else
869+
} else {
868870
worker_context_->Exit(exit_code);
871+
}
869872
}
870873

871874
void Environment::stop_sub_worker_contexts() {
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ tracing::AgentWriterHandle* GetTracingAgentWriter() {
337337
return v8_platform.GetTracingAgentWriter();
338338
}
339339

340+
void DisposePlatform() {
341+
v8_platform.Dispose();
342+
}
343+
340344
#ifdef __POSIX__
341345
static const unsigned kMaxSignal = 32;
342346
#endif
Collapse file

‎src/node_internals.h‎

Copy file name to clipboardExpand all lines: src/node_internals.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ int ThreadPoolWork::CancelWork() {
358358
}
359359

360360
tracing::AgentWriterHandle* GetTracingAgentWriter();
361+
void DisposePlatform();
361362

362363
static inline const char* errno_string(int errorno) {
363364
#define ERRNO_CASE(e) case e: return #e;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.