소스 검색

Update PyException.c

blueloveTH 5 일 전
부모
커밋
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;
     int max_frame_dumps = py_debugger_status() == 1 ? 31 : 7;
     if(ud->stacktrace.length >= max_frame_dumps) return;
     if(ud->stacktrace.length >= max_frame_dumps) return;
     BaseExceptionFrame* frame_dump = c11_vector__emplace(&ud->stacktrace);
     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);
     PK_INCREF(src);
     frame_dump->src = src;
     frame_dump->src = src;
     frame_dump->lineno = lineno;
     frame_dump->lineno = lineno;