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 97bd9cc

Browse filesBrowse files
hybristjoyeecheung
authored andcommitted
src: fix uninitialized field access in AsyncHooks
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com> PR-URL: #48566 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
1 parent 2c56835 commit 97bd9cc
Copy full SHA for 97bd9cc

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

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

‎src/env.cc‎

Copy file name to clipboardExpand all lines: src/env.cc
+5-7Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,13 @@ bool AsyncHooks::pop_async_context(double async_id) {
170170
}
171171

172172
void AsyncHooks::clear_async_id_stack() {
173-
if (env()->can_call_into_js()) {
173+
if (!js_execution_async_resources_.IsEmpty() && env()->can_call_into_js()) {
174174
Isolate* isolate = env()->isolate();
175175
HandleScope handle_scope(isolate);
176-
if (!js_execution_async_resources_.IsEmpty()) {
177-
USE(PersistentToLocal::Strong(js_execution_async_resources_)
178-
->Set(env()->context(),
179-
env()->length_string(),
180-
Integer::NewFromUnsigned(isolate, 0)));
181-
}
176+
USE(PersistentToLocal::Strong(js_execution_async_resources_)
177+
->Set(env()->context(),
178+
env()->length_string(),
179+
Integer::NewFromUnsigned(isolate, 0)));
182180
}
183181

184182
native_execution_async_resources_.clear();
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,10 @@ class Environment : public MemoryRetainer {
10151015
uv_async_t task_queues_async_;
10161016
int64_t task_queues_async_refs_ = 0;
10171017

1018+
// These may be read by ctors and should be listed before complex fields.
1019+
std::atomic_bool is_stopping_{false};
1020+
std::atomic_bool can_call_into_js_{true};
1021+
10181022
AsyncHooks async_hooks_;
10191023
ImmediateInfo immediate_info_;
10201024
AliasedInt32Array timeout_info_;
@@ -1092,7 +1096,6 @@ class Environment : public MemoryRetainer {
10921096

10931097
bool has_serialized_options_ = false;
10941098

1095-
std::atomic_bool can_call_into_js_ { true };
10961099
uint64_t flags_;
10971100
uint64_t thread_id_;
10981101
std::unordered_set<worker::Worker*> sub_worker_contexts_;
@@ -1150,8 +1153,6 @@ class Environment : public MemoryRetainer {
11501153
CleanupQueue cleanup_queue_;
11511154
bool started_cleanup_ = false;
11521155

1153-
std::atomic_bool is_stopping_ { false };
1154-
11551156
std::unordered_set<int> unmanaged_fds_;
11561157

11571158
std::function<void(Environment*, ExitCode)> process_exit_handler_{

0 commit comments

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