Skip to content

GH-91048: Correct error path in testexternalinspection #129557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Modules/_testexternalinspection.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ get_py_runtime(pid_t pid)
{
uintptr_t address = search_map_for_section(pid, "PyRuntime", "libpython");
if (address == 0) {
PyErr_Clear();
address = search_map_for_section(pid, "PyRuntime", "python");
}
return address;
Expand Down Expand Up @@ -1457,6 +1458,13 @@ get_stack_trace(PyObject* self, PyObject* args)
}

uintptr_t runtime_start_address = get_py_runtime(pid);
if (runtime_start_address == 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(
PyExc_RuntimeError, "Failed to get .PyRuntime address");
}
return NULL;
}
struct _Py_DebugOffsets local_debug_offsets;

if (read_offsets(pid, &runtime_start_address, &local_debug_offsets)) {
Expand Down Expand Up @@ -1510,6 +1518,13 @@ get_async_stack_trace(PyObject* self, PyObject* args)
}

uintptr_t runtime_start_address = get_py_runtime(pid);
if (runtime_start_address == 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(
PyExc_RuntimeError, "Failed to get .PyRuntime address");
}
return NULL;
}
struct _Py_DebugOffsets local_debug_offsets;

if (read_offsets(pid, &runtime_start_address, &local_debug_offsets)) {
Expand Down
Loading