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 0c19621

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 f5494fa commit 0c19621
Copy full SHA for 0c19621

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
@@ -168,15 +168,13 @@ bool AsyncHooks::pop_async_context(double async_id) {
168168
}
169169

170170
void AsyncHooks::clear_async_id_stack() {
171-
if (env()->can_call_into_js()) {
171+
if (!js_execution_async_resources_.IsEmpty() && env()->can_call_into_js()) {
172172
Isolate* isolate = env()->isolate();
173173
HandleScope handle_scope(isolate);
174-
if (!js_execution_async_resources_.IsEmpty()) {
175-
USE(PersistentToLocal::Strong(js_execution_async_resources_)
176-
->Set(env()->context(),
177-
env()->length_string(),
178-
Integer::NewFromUnsigned(isolate, 0)));
179-
}
174+
USE(PersistentToLocal::Strong(js_execution_async_resources_)
175+
->Set(env()->context(),
176+
env()->length_string(),
177+
Integer::NewFromUnsigned(isolate, 0)));
180178
}
181179

182180
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
@@ -969,6 +969,10 @@ class Environment : public MemoryRetainer {
969969
uv_async_t task_queues_async_;
970970
int64_t task_queues_async_refs_ = 0;
971971

972+
// These may be read by ctors and should be listed before complex fields.
973+
std::atomic_bool is_stopping_{false};
974+
std::atomic_bool can_call_into_js_{true};
975+
972976
AsyncHooks async_hooks_;
973977
ImmediateInfo immediate_info_;
974978
AliasedInt32Array timeout_info_;
@@ -1034,7 +1038,6 @@ class Environment : public MemoryRetainer {
10341038

10351039
bool has_serialized_options_ = false;
10361040

1037-
std::atomic_bool can_call_into_js_ { true };
10381041
uint64_t flags_;
10391042
uint64_t thread_id_;
10401043
std::unordered_set<worker::Worker*> sub_worker_contexts_;
@@ -1092,8 +1095,6 @@ class Environment : public MemoryRetainer {
10921095
CleanupQueue cleanup_queue_;
10931096
bool started_cleanup_ = false;
10941097

1095-
std::atomic_bool is_stopping_ { false };
1096-
10971098
std::unordered_set<int> unmanaged_fds_;
10981099

10991100
std::function<void(Environment*, int)> process_exit_handler_ {

0 commit comments

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