@@ -2118,6 +2118,7 @@ parse_frame_from_chunks(
21182118 PyObject * * result ,
21192119 uintptr_t address ,
21202120 uintptr_t * previous_frame ,
2121+ uintptr_t * stackpointer ,
21212122 StackChunkList * chunks
21222123) {
21232124 void * frame_ptr = find_frame_in_chunks (chunks , address );
@@ -2128,6 +2129,7 @@ parse_frame_from_chunks(
21282129
21292130 char * frame = (char * )frame_ptr ;
21302131 * previous_frame = GET_MEMBER (uintptr_t , frame , unwinder -> debug_offsets .interpreter_frame .previous );
2132+ * stackpointer = GET_MEMBER (uintptr_t , frame , unwinder -> debug_offsets .interpreter_frame .stackpointer );
21312133 uintptr_t code_object = GET_MEMBER_NO_TAG (uintptr_t , frame_ptr , unwinder -> debug_offsets .interpreter_frame .executable );
21322134 int frame_valid = is_frame_valid (unwinder , (uintptr_t )frame , code_object );
21332135 if (frame_valid != 1 ) {
@@ -2470,6 +2472,7 @@ process_frame_chain(
24702472 while ((void * )frame_addr != NULL ) {
24712473 PyObject * frame = NULL ;
24722474 uintptr_t next_frame_addr = 0 ;
2475+ uintptr_t stackpointer = 0 ;
24732476
24742477 if (++ frame_count > MAX_FRAMES ) {
24752478 PyErr_SetString (PyExc_RuntimeError , "Too many stack frames (possible infinite loop)" );
@@ -2478,7 +2481,7 @@ process_frame_chain(
24782481 }
24792482
24802483 // Try chunks first, fallback to direct memory read
2481- if (parse_frame_from_chunks (unwinder , & frame , frame_addr , & next_frame_addr , chunks ) < 0 ) {
2484+ if (parse_frame_from_chunks (unwinder , & frame , frame_addr , & next_frame_addr , & stackpointer , chunks ) < 0 ) {
24822485 PyErr_Clear ();
24832486 uintptr_t address_of_code_object = 0 ;
24842487 if (parse_frame_object (unwinder , & frame , frame_addr , & address_of_code_object ,& next_frame_addr ) < 0 ) {
@@ -2502,9 +2505,7 @@ process_frame_chain(
25022505 // Otherwise, check for native frames to insert:
25032506 else if (unwinder -> native ) {
25042507 // Topmost frame spilled its stack pointer for a native call:
2505- if (PyList_GET_SIZE (frame_info ) == 0 &&
2506- GET_MEMBER (uintptr_t , frame_addr , unwinder -> debug_offsets .interpreter_frame .stackpointer ))
2507- {
2508+ if (PyList_GET_SIZE (frame_info ) == 0 && stackpointer ) {
25082509 extra_frame = & _Py_STR (native );
25092510 }
25102511 // Or, we've reached an interpreter trampoline frame:
0 commit comments