| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent be12749 commit 3e2fdff
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -127,6 +127,11 @@ inline void AsyncHooks::SetJSPromiseHooks(v8::Local<v8::Function> init, | |||
| 127 | 127 | js_promise_hooks_[2].Reset(env()->isolate(), after); | |
| 128 | 128 | js_promise_hooks_[3].Reset(env()->isolate(), resolve); | |
| 129 | 129 | for (auto it = contexts_.begin(); it != contexts_.end(); it++) { | |
| 130 | + if (it->IsEmpty()) { | ||
| 131 | + it = contexts_.erase(it); | ||
| 132 | + it--; | ||
| 133 | + continue; | ||
| 134 | + } | ||
| 130 | 135 | PersistentToLocal::Weak(env()->isolate(), *it) | |
| 131 | 136 | ->SetPromiseHooks(init, before, after, resolve); | |
| 132 | 137 | } | |
@@ -279,8 +284,13 @@ inline void AsyncHooks::RemoveContext(v8::Local<v8::Context> ctx) { | |||
| 279 | 284 | v8::Isolate* isolate = env()->isolate(); | |
| 280 | 285 | v8::HandleScope handle_scope(isolate); | |
| 281 | 286 | for (auto it = contexts_.begin(); it != contexts_.end(); it++) { | |
| 287 | + if (it->IsEmpty()) { | ||
| 288 | + it = contexts_.erase(it); | ||
| 289 | + it--; | ||
| 290 | + continue; | ||
| 291 | + } | ||
| 282 | 292 | v8::Local<v8::Context> saved_context = | |
| 283 | - PersistentToLocal::Weak(env()->isolate(), *it); | ||
| 293 | + PersistentToLocal::Weak(isolate, *it); | ||
| 284 | 294 | if (saved_context == ctx) { | |
| 285 | 295 | it->Reset(); | |
| 286 | 296 | contexts_.erase(it); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,15 @@ | |||
| 1 | + // Flags: --expose-gc | ||
| 2 | + 'use strict'; | ||
| 3 | + | ||
| 4 | + require('../common'); | ||
| 5 | + const asyncHooks = require('async_hooks'); | ||
| 6 | + const vm = require('vm'); | ||
| 7 | + | ||
| 8 | + // This is a regression test for https://github.com/nodejs/node/issues/39019 | ||
| 9 | + // | ||
| 10 | + // It should not segfault. | ||
| 11 | + | ||
| 12 | + const hook = asyncHooks.createHook({ init() {} }).enable(); | ||
| 13 | + vm.createContext(); | ||
| 14 | + globalThis.gc(); | ||
| 15 | + hook.disable(); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments