Skip to content

Commit ec4be2d

Browse files
jasnelltargos
authored andcommittedMay 1, 2021
src: fix finalization crash
PR-URL: #38250 Fixes: #38040 Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 530e69e commit ec4be2d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed
 

‎src/js_native_api_v8.cc

+4
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ class Reference : public RefBase {
372372

373373
protected:
374374
inline void Finalize(bool is_env_teardown = false) override {
375+
if (is_env_teardown) env_teardown_finalize_started_ = true;
376+
if (!is_env_teardown && env_teardown_finalize_started_) return;
377+
375378
// During env teardown, `~napi_env()` alone is responsible for finalizing.
376379
// Thus, we don't want any stray gc passes to trigger a second call to
377380
// `Finalize()`, so let's reset the persistent here if nothing is
@@ -405,6 +408,7 @@ class Reference : public RefBase {
405408
data.GetParameter()->Finalize();
406409
}
407410

411+
bool env_teardown_finalize_started_ = false;
408412
v8impl::Persistent<v8::Value> _persistent;
409413
};
410414

0 commit comments

Comments
 (0)