Skip to content

Commit 49b1103

Browse files
authored
GH-91048: Correct error path in testexternalinspection (#129557)
1 parent 2dd0188 commit 49b1103

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Modules/_testexternalinspection.c

+15
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ get_py_runtime(pid_t pid)
410410
{
411411
uintptr_t address = search_map_for_section(pid, "PyRuntime", "libpython");
412412
if (address == 0) {
413+
PyErr_Clear();
413414
address = search_map_for_section(pid, "PyRuntime", "python");
414415
}
415416
return address;
@@ -1458,6 +1459,13 @@ get_stack_trace(PyObject* self, PyObject* args)
14581459
}
14591460

14601461
uintptr_t runtime_start_address = get_py_runtime(pid);
1462+
if (runtime_start_address == 0) {
1463+
if (!PyErr_Occurred()) {
1464+
PyErr_SetString(
1465+
PyExc_RuntimeError, "Failed to get .PyRuntime address");
1466+
}
1467+
return NULL;
1468+
}
14611469
struct _Py_DebugOffsets local_debug_offsets;
14621470

14631471
if (read_offsets(pid, &runtime_start_address, &local_debug_offsets)) {
@@ -1511,6 +1519,13 @@ get_async_stack_trace(PyObject* self, PyObject* args)
15111519
}
15121520

15131521
uintptr_t runtime_start_address = get_py_runtime(pid);
1522+
if (runtime_start_address == 0) {
1523+
if (!PyErr_Occurred()) {
1524+
PyErr_SetString(
1525+
PyExc_RuntimeError, "Failed to get .PyRuntime address");
1526+
}
1527+
return NULL;
1528+
}
15141529
struct _Py_DebugOffsets local_debug_offsets;
15151530

15161531
if (read_offsets(pid, &runtime_start_address, &local_debug_offsets)) {

0 commit comments

Comments
 (0)