Skip to content

Commit 6752ffb

Browse files
fix a couple of crash bugs with stackless JSON conversion
1 parent e371979 commit 6752ffb

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

core/vm.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,19 @@ class Stack {
336336

337337
if (name == "")
338338
name = "anonymous";
339+
339340
if (dynamic_cast<const HeapObject *>(e)) {
340341
return "object <" + name + ">";
342+
} else if (dynamic_cast<const HeapArray *>(e)) {
343+
return "array <" + name + ">";
341344
} else if (auto *thunk = dynamic_cast<const HeapThunk *>(e)) {
342345
if (thunk->name == nullptr) {
343346
return ""; // Argument of builtin, or root (since top level functions).
344347
} else {
345348
return "thunk <" + encode_utf8(thunk->name->name) + ">";
346349
}
347350
} else {
351+
assert(dynamic_cast<const HeapClosure *>(e));
348352
const auto *func = static_cast<const HeapClosure *>(e);
349353
if (func->body == nullptr) {
350354
return "builtin function <" + func->builtinName + ">";
@@ -3354,7 +3358,7 @@ class Interpreter {
33543358
const auto loc = f.location;
33553359
const int indentLevel = (f.indentLevel == 0) ? 0 : f.indentLevel + 1;
33563360
// Add a call frame for the JSON conversion, used to apply depth limit.
3357-
stack.newCall(thunk->body->location, arr, nullptr, 0, BindingFrame{});
3361+
stack.newCall(thunk->body ? thunk->body->location : LocationRange("unknown"), arr, nullptr, 0, BindingFrame{});
33583362
stack.newFrame(FRAME_TO_JSON, loc);
33593363
stack.top().indentLevel = indentLevel;
33603364
if (thunk->filled) {

0 commit comments

Comments
 (0)