blueloveTH 5 дней назад
Родитель
Сommit
de8351ed0f
1 измененных файлов с 4 добавлено и 0 удалено
  1. 4 0
      src/public/PyException.c

+ 4 - 0
src/public/PyException.c

@@ -15,6 +15,10 @@ void py_BaseException__stpush(py_Frame* frame,
     int max_frame_dumps = py_debugger_status() == 1 ? 31 : 7;
     if(ud->stacktrace.length >= max_frame_dumps) return;
     BaseExceptionFrame* frame_dump = c11_vector__emplace(&ud->stacktrace);
+    // `locals` and `globals` are only filled in when the debugger is attached, but the GC
+    // walks them unconditionally; nil them out before anything below can allocate
+    py_newnil(&frame_dump->locals);
+    py_newnil(&frame_dump->globals);
     PK_INCREF(src);
     frame_dump->src = src;
     frame_dump->lineno = lineno;