Skip to content

Commit 0bedfa7

Browse files
committed
patch the inspector stack-trace-impl to not crash when an exception is thrown while evaluating expressions in the devtools console
1 parent 29a1bf2 commit 0bedfa7

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

runtime/src/main/jni/v8_inspector/src/inspector/v8-debugger.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ std::unique_ptr<V8StackTraceImpl> V8Debugger::createStackTrace(
894894
v8::Local<v8::StackTrace> stackTrace) {
895895
int contextGroupId =
896896
m_isolate->InContext() ? getGroupId(m_isolate->GetCurrentContext()) : 0;
897-
return V8StackTraceImpl::create(this, contextGroupId, stackTrace,
897+
return V8StackTraceImpl::create(m_isolate, this, contextGroupId, stackTrace,
898898
V8StackTraceImpl::maxCallStackSizeToCapture);
899899
}
900900

runtime/src/main/jni/v8_inspector/src/inspector/v8-stack-trace-impl.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ void V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(
105105
}
106106

107107
// static
108-
std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(
108+
std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(v8::Isolate *isolate,
109109
V8Debugger* debugger, int contextGroupId,
110110
v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize,
111111
const String16& description) {
112-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
112+
113113
v8::HandleScope scope(isolate);
114114
std::vector<V8StackTraceImpl::Frame> frames;
115115
if (!stackTrace.IsEmpty())
@@ -170,7 +170,7 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture(
170170
stackTrace = v8::StackTrace::CurrentStackTrace(
171171
isolate, static_cast<int>(maxStackSize), stackTraceOptions);
172172
}
173-
return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace,
173+
return V8StackTraceImpl::create(isolate, debugger, contextGroupId, stackTrace,
174174
maxStackSize, description);
175175
}
176176

@@ -247,7 +247,7 @@ V8StackTraceImpl::buildInspectorObjectForTail(V8Debugger* debugger) const {
247247
v8::HandleScope handleScope(v8::Isolate::GetCurrent());
248248
// Next call collapses possible empty stack and ensures
249249
// maxAsyncCallChainDepth.
250-
std::unique_ptr<V8StackTraceImpl> fullChain = V8StackTraceImpl::create(
250+
std::unique_ptr<V8StackTraceImpl> fullChain = V8StackTraceImpl::create(v8::Isolate::GetCurrent(),
251251
debugger, m_contextGroupId, v8::Local<v8::StackTrace>(),
252252
V8StackTraceImpl::maxCallStackSizeToCapture);
253253
if (!fullChain || !fullChain->m_parent) return nullptr;

runtime/src/main/jni/v8_inspector/src/inspector/v8-stack-trace-impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class V8StackTraceImpl final : public V8StackTrace {
5454

5555
static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*,
5656
bool capture);
57-
static std::unique_ptr<V8StackTraceImpl> create(
57+
static std::unique_ptr<V8StackTraceImpl> create(v8::Isolate* isolate,
5858
V8Debugger*, int contextGroupId, v8::Local<v8::StackTrace>,
5959
size_t maxStackSize, const String16& description = String16());
6060
static std::unique_ptr<V8StackTraceImpl> capture(

0 commit comments

Comments
 (0)