@@ -770,20 +770,6 @@ get_task_frame(RemoteUnwinderObject *unwinder, uintptr_t task_addr, uintptr_t *f
770770 return 0 ;
771771 }
772772
773- int8_t frame_state ;
774- if (_Py_RemoteDebug_PagedReadRemoteMemory (
775- & unwinder -> handle ,
776- running_coro_addr + (uintptr_t )unwinder -> debug_offsets .gen_object .gi_frame_state ,
777- sizeof (frame_state ),
778- & frame_state ) < 0 ) {
779- set_exception_cause (unwinder , PyExc_RuntimeError , "Running task coro frame state read failed" );
780- return -1 ;
781- }
782- if (frame_state != FRAME_EXECUTING ) {
783- * frame_addr = 0 ;
784- return 0 ;
785- }
786-
787773 * frame_addr = running_coro_addr + (uintptr_t )unwinder -> debug_offsets .gen_object .gi_iframe ;
788774 return 0 ;
789775}
@@ -799,6 +785,7 @@ parse_async_frame_chain(
799785 uintptr_t address_of_thread ,
800786 uintptr_t running_task_frame
801787) {
788+ Py_ssize_t coro_chain_size = PyList_GET_SIZE (calls );
802789 uintptr_t address_of_current_frame ;
803790 if (find_running_frame (unwinder , address_of_thread , & address_of_current_frame ) < 0 ) {
804791 set_exception_cause (unwinder , PyExc_RuntimeError , "Running frame search failed in async chain" );
@@ -844,11 +831,12 @@ parse_async_frame_chain(
844831 // Stop at the task's own frame. Code objects are shared by
845832 // recursive calls, so they cannot identify it.
846833 if (this_frame == running_task_frame ) {
847- break ;
834+ return PyList_SetSlice ( calls , 0 , coro_chain_size , NULL ) ;
848835 }
849836 }
850837
851- return 0 ;
838+ // gh-159645: keep the coroutine chain if the task's frame was not found.
839+ return PyList_SetSlice (calls , coro_chain_size , PY_SSIZE_T_MAX , NULL );
852840}
853841
854842/* ============================================================================
@@ -990,7 +978,7 @@ process_running_task_chain(
990978 return -1 ;
991979 }
992980
993- // gh-159645: the coroutine isn't running, so keep its await chain .
981+ // gh-159645: non-native coroutines have no frame to look for .
994982 if (running_task_frame == 0 ) {
995983 return process_task_waiters (unwinder , result );
996984 }
@@ -1010,12 +998,6 @@ process_running_task_chain(
1010998 PyObject * frame_chain = PyStructSequence_GET_ITEM (coro_info , 0 );
1011999 assert (frame_chain != NULL );
10121000
1013- // Clear the coro_chain
1014- if (PyList_Clear (frame_chain ) < 0 ) {
1015- set_exception_cause (unwinder , PyExc_RuntimeError , "Failed to clear coroutine chain" );
1016- return -1 ;
1017- }
1018-
10191001 // Add the chain from the current frame to this task
10201002 if (parse_async_frame_chain (unwinder , frame_chain , thread_state_addr , running_task_frame ) < 0 ) {
10211003 return -1 ;
0 commit comments