Skip to content

Commit e5129df

Browse files
committed
Use GetEnteredOrMicrotaskContext in GetContext to avoid crashes with GetCurrentContext
1 parent f20a51e commit e5129df

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

bindings/profilers/wall.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,12 +1080,10 @@ ContextPtr WallProfiler::GetContextPtrSignalSafe(Isolate* isolate) {
10801080
std::atomic_signal_fence(std::memory_order_acquire);
10811081
if (curGcCount > 0) {
10821082
return gcContext;
1083-
} else if (isolate->InContext()) {
1084-
auto handleScope = HandleScope(isolate);
1085-
return GetContextPtr(isolate);
10861083
}
1087-
// not in a V8 Context
1088-
return std::shared_ptr<Global<Value>>();
1084+
1085+
auto handleScope = HandleScope(isolate);
1086+
return GetContextPtr(isolate);
10891087
}
10901088

10911089
ContextPtr WallProfiler::GetContextPtr(Isolate* isolate) {
@@ -1099,7 +1097,7 @@ ContextPtr WallProfiler::GetContextPtr(Isolate* isolate) {
10991097
auto cped = isolate->GetContinuationPreservedEmbedderData();
11001098
RETURN_EMPTY_IF(!cped->IsObject());
11011099

1102-
auto v8Ctx = isolate->GetCurrentContext();
1100+
auto v8Ctx = isolate->GetEnteredOrMicrotaskContext();
11031101
RETURN_EMPTY_IF(v8Ctx.IsEmpty());
11041102

11051103
auto cpedObj = cped.As<Object>();

0 commit comments

Comments
 (0)