Skip to content

Commit 0f6d194

Browse files
santigimenotargos
authored andcommitted
src: fix crash on FSReqPromise destructor
We are deciding whether to end `fs` promises by checking `can_call_into_js()` whereas in the `FSReqPromise` destructor we're using the `is_stopping()` check. Though this may look as semantically correct it has issues because though both values are modified before termination on `Environment::ExitEnv()` and both are atomic they are not syncronized together so it may happen that when reaching the destructor `call_into_js` may be set to `false` whereas `is_stopping` remains `false` causing the crash. Fix this by checking with `can_call_into_js()` also in the destructor. Fixes: #43499 PR-URL: #43533 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent a0e7b99 commit 0f6d194

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/node_file-inl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ FSReqPromise<AliasedBufferT>::~FSReqPromise() {
159159
// Validate that the promise was explicitly resolved or rejected but only if
160160
// the Isolate is not terminating because in this case the promise might have
161161
// not finished.
162-
if (!env()->is_stopping()) CHECK(finished_);
162+
CHECK_IMPLIES(!finished_, !env()->can_call_into_js());
163163
}
164164

165165
template <typename AliasedBufferT>

0 commit comments

Comments
 (0)