@@ -163,21 +163,23 @@ find_frame_in_chunks(StackChunkList *chunks, uintptr_t remote_ptr)
163163 * FRAME PARSING FUNCTIONS
164164 * ============================================================================ */
165165
166+ enum { FRAME_PARSE_INTERPRETER = 2 };
167+
166168int
167169is_frame_valid (
168170 RemoteUnwinderObject * unwinder ,
169171 uintptr_t frame_addr ,
170172 uintptr_t code_object_addr
171173) {
172174 if ((void * )code_object_addr == NULL ) {
173- return 0 ;
175+ return 0 ; // Frame being cleared
174176 }
175177
176178 void * frame = (void * )frame_addr ;
177179
178180 char owner = GET_MEMBER (char , frame , unwinder -> debug_offsets .interpreter_frame .owner );
179181 if (owner == FRAME_OWNED_BY_INTERPRETER ) {
180- return 0 ; // C frame or sentinel base frame
182+ return FRAME_PARSE_INTERPRETER ; // C frame or sentinel base frame
181183 }
182184
183185 if (owner != FRAME_OWNED_BY_GENERATOR && owner != FRAME_OWNED_BY_THREAD ) {
@@ -313,6 +315,7 @@ process_frame_chain(
313315 ctx -> last_frame_visited = 0 ;
314316
315317 while ((void * )frame_addr != NULL ) {
318+ int parse_result = 0 ;
316319 PyObject * frame = NULL ;
317320 uintptr_t next_frame_addr = 0 ;
318321 uintptr_t stackpointer = 0 ;
@@ -326,14 +329,15 @@ process_frame_chain(
326329 assert (frame_count <= MAX_FRAMES );
327330
328331 if (ctx -> chunks && ctx -> chunks -> count > 0 ) {
329- if (parse_frame_from_chunks (unwinder , & frame , frame_addr , & next_frame_addr , & stackpointer , ctx -> chunks ) == 0 ) {
332+ parse_result = parse_frame_from_chunks (
333+ unwinder , & frame , frame_addr , & next_frame_addr , & stackpointer , ctx -> chunks );
334+ if (parse_result == 0 ) {
330335 goto parsed_frame ;
331336 }
332337 PyErr_Clear ();
333338 }
334339 {
335340 uintptr_t address_of_code_object = 0 ;
336- int parse_result ;
337341 if (ctx -> prefetch .frame && ctx -> prefetch .frame_addr == frame_addr ) {
338342 parse_result = parse_frame_buffer (
339343 unwinder , & frame , ctx -> prefetch .frame ,
@@ -368,6 +372,7 @@ process_frame_chain(
368372 // returning into.
369373 else if (unwinder -> native &&
370374 frame == NULL &&
375+ parse_result == FRAME_PARSE_INTERPRETER &&
371376 next_frame_addr &&
372377 PyList_GET_SIZE (ctx -> frame_info ) > 0 &&
373378 !(unwinder -> gc && next_frame_addr == ctx -> gc_frame ))
0 commit comments