GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Revert "[3.15] gh-158522: Fix truncated stack for a task whose corout… · pablogsal/cpython@b3cfee3

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Lib/test
    • test_external_inspection.py
  • Misc/NEWS.d/next/Library
    • 2026-09-30-20-09-46.gh-issue-158522.L6j7tU.rst
  • Modules/_remote_debugging
    • _remote_debugging.h
    • asyncio.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Lib/test/test_external_inspection.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_external_inspection.py
-16Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -492,22 +492,6 @@ async def main():
492492
self.assertIn(main_name, names)
493493
self.assertEqual([len(n) for n in names if n.startswith("x")], [255])
494494

495-
@skip_if_not_supported
496-
def test_recursive_coroutine_stack_is_not_truncated(self):
497-
# gh-158522
498-
async def rec(n):
499-
if n:
500-
return await rec(n - 1)
501-
return [
502-
frame.funcname.rpartition(".")[2]
503-
for task in RemoteUnwinder(
504-
os.getpid()).get_async_stack_trace()[0].awaited_by
505-
for coro in task.coroutine_stack
506-
for frame in coro.call_stack
507-
]
508-
509-
self.assertEqual(asyncio.run(rec(3)), ["rec"] * 4)
510-
511495
@skip_if_not_supported
512496
@unittest.skipIf(
513497
sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED,
Collapse file

‎Misc/NEWS.d/next/Library/2026-09-30-20-09-46.gh-issue-158522.L6j7tU.rst‎

Copy file name to clipboardExpand all lines: Misc/NEWS.d/next/Library/2026-09-30-20-09-46.gh-issue-158522.L6j7tU.rst
-2Lines changed: 0 additions & 2 deletions
This file was deleted.
Collapse file

‎Modules/_remote_debugging/_remote_debugging.h‎

Copy file name to clipboardExpand all lines: Modules/_remote_debugging/_remote_debugging.h
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ extern int parse_async_frame_chain(
729729
RemoteUnwinderObject *unwinder,
730730
PyObject *calls,
731731
uintptr_t address_of_thread,
732-
uintptr_t running_task_frame
732+
uintptr_t running_task_code_obj
733733
);
734734

735735
extern int process_single_task_node(
@@ -745,10 +745,10 @@ extern int find_running_task_in_thread(
745745
uintptr_t *running_task_addr
746746
);
747747

748-
extern int get_task_frame(
748+
extern int get_task_code_object(
749749
RemoteUnwinderObject *unwinder,
750750
uintptr_t task_addr,
751-
uintptr_t *frame_addr
751+
uintptr_t *code_obj_addr
752752
);
753753

754754
extern int append_awaited_by(
Collapse file

‎Modules/_remote_debugging/asyncio.c‎

Copy file name to clipboardExpand all lines: Modules/_remote_debugging/asyncio.c
+21-11Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ find_running_task_in_thread(
716716
}
717717

718718
int
719-
get_task_frame(RemoteUnwinderObject *unwinder, uintptr_t task_addr, uintptr_t *frame_addr) {
719+
get_task_code_object(RemoteUnwinderObject *unwinder, uintptr_t task_addr, uintptr_t *code_obj_addr) {
720720
uintptr_t running_coro_addr = 0;
721721

722722
if(read_py_ptr(
@@ -733,7 +733,21 @@ get_task_frame(RemoteUnwinderObject *unwinder, uintptr_t task_addr, uintptr_t *f
733733
return -1;
734734
}
735735

736-
*frame_addr = running_coro_addr + (uintptr_t)unwinder->debug_offsets.gen_object.gi_iframe;
736+
// note: genobject's gi_iframe is an embedded struct so the address to
737+
// the offset leads directly to its first field: f_executable
738+
if (read_py_ptr(
739+
unwinder,
740+
running_coro_addr + (uintptr_t)unwinder->debug_offsets.gen_object.gi_iframe, code_obj_addr) < 0) {
741+
set_exception_cause(unwinder, PyExc_RuntimeError, "Failed to read running task code object");
742+
return -1;
743+
}
744+
745+
if (*code_obj_addr == 0) {
746+
PyErr_SetString(PyExc_RuntimeError, "Running task code object is NULL");
747+
set_exception_cause(unwinder, PyExc_RuntimeError, "Running task code object address is NULL");
748+
return -1;
749+
}
750+
737751
return 0;
738752
}
739753

@@ -746,7 +760,7 @@ parse_async_frame_chain(
746760
RemoteUnwinderObject *unwinder,
747761
PyObject *calls,
748762
uintptr_t address_of_thread,
749-
uintptr_t running_task_frame
763+
uintptr_t running_task_code_obj
750764
) {
751765
uintptr_t address_of_current_frame;
752766
if (find_running_frame(unwinder, address_of_thread, &address_of_current_frame) < 0) {
@@ -763,8 +777,6 @@ parse_async_frame_chain(
763777
}
764778
PyObject* frame_info = NULL;
765779
uintptr_t address_of_code_object;
766-
767-
uintptr_t this_frame = address_of_current_frame;
768780
int res = parse_frame_object(
769781
unwinder,
770782
&frame_info,
@@ -790,9 +802,7 @@ parse_async_frame_chain(
790802

791803
Py_DECREF(frame_info);
792804

793-
// Stop at the task's own frame. Code objects are shared by
794-
// recursive calls, so they cannot identify it.
795-
if (this_frame == running_task_frame) {
805+
if (address_of_code_object == running_task_code_obj) {
796806
break;
797807
}
798808
}
@@ -928,8 +938,8 @@ process_running_task_chain(
928938
uintptr_t thread_state_addr,
929939
PyObject *result
930940
) {
931-
uintptr_t running_task_frame = 0;
932-
if(get_task_frame(unwinder, running_task_addr, &running_task_frame) < 0) {
941+
uintptr_t running_task_code_obj = 0;
942+
if(get_task_code_object(unwinder, running_task_addr, &running_task_code_obj) < 0) {
933943
return -1;
934944
}
935945

@@ -961,7 +971,7 @@ process_running_task_chain(
961971
}
962972

963973
// Add the chain from the current frame to this task
964-
if (parse_async_frame_chain(unwinder, frame_chain, thread_state_addr, running_task_frame) < 0) {
974+
if (parse_async_frame_chain(unwinder, frame_chain, thread_state_addr, running_task_code_obj) < 0) {
965975
return -1;
966976
}
967977

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.