Skip to content

Commit b740324

Browse files
joyeecheungtargos
authored andcommitted
src: use v8::Isolate::TryGetCurrent() in DumpJavaScriptBacktrace()
It was using Isolate::GetCurrent() which DCHECK on nullptr, even though what we wanted was to return early if it is nullptr. PR-URL: #50518 Refs: #50242 Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent aa8feea commit b740324

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/debug_utils.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ void DumpNativeBacktrace(FILE* fp) {
319319
}
320320

321321
void DumpJavaScriptBacktrace(FILE* fp) {
322-
v8::Isolate* isolate = v8::Isolate::GetCurrent();
322+
v8::Isolate* isolate = v8::Isolate::TryGetCurrent();
323323
if (isolate == nullptr) {
324324
return;
325325
}

test/cctest/test_util.cc

+4
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,7 @@ TEST(UtilTest, SPrintF) {
299299
const std::string with_zero = std::string("a") + '\0' + 'b';
300300
EXPECT_EQ(SPrintF("%s", with_zero), with_zero);
301301
}
302+
303+
TEST(UtilTest, DumpJavaScriptStackWithNoIsolate) {
304+
node::DumpJavaScriptBacktrace(stderr);
305+
}

0 commit comments

Comments
 (0)