@@ -22,7 +22,7 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle)
2222 address = search_windows_map_for_section (handle , "AsyncioD" , L"_asyncio" ,
2323 NULL );
2424 if (address == 0 ) {
25- if (!_Py_RemoteDebug_HasPermissionError ()) {
25+ if (!_Py_RemoteDebug_IsFatalReadError ()) {
2626 PyObject * exc = PyErr_GetRaisedException ();
2727 PyErr_SetString (PyExc_RuntimeError , "Failed to find the AsyncioDebug section in the process." );
2828 _PyErr_ChainExceptions1 (exc );
@@ -33,7 +33,7 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle)
3333 address = search_linux_map_for_section (handle , "AsyncioDebug" , "python" ,
3434 NULL );
3535 if (address == 0 ) {
36- if (!_Py_RemoteDebug_HasPermissionError ()) {
36+ if (!_Py_RemoteDebug_IsFatalReadError ()) {
3737 PyObject * exc = PyErr_GetRaisedException ();
3838 PyErr_SetString (PyExc_RuntimeError , "Failed to find the AsyncioDebug section in the process." );
3939 _PyErr_ChainExceptions1 (exc );
@@ -42,7 +42,7 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle)
4242#elif defined(__APPLE__ ) && TARGET_OS_OSX
4343 address = search_loaded_images_for_section (handle , "AsyncioDebug" , NULL );
4444 if (address == 0 ) {
45- if (!_Py_RemoteDebug_HasPermissionError ()) {
45+ if (!_Py_RemoteDebug_IsFatalReadError ()) {
4646 PyObject * exc = PyErr_GetRaisedException ();
4747 PyErr_SetString (PyExc_RuntimeError , "Failed to find the AsyncioDebug section in the process." );
4848 _PyErr_ChainExceptions1 (exc );
@@ -92,12 +92,22 @@ ensure_async_debug_offsets(RemoteUnwinderObject *unwinder)
9292 return -1 ;
9393 }
9494 if (result < 0 ) {
95- if (!_Py_RemoteDebug_HasPermissionError ()) {
96- PyErr_Clear ();
97- PyErr_SetString (PyExc_RuntimeError , "AsyncioDebug section not available" );
98- set_exception_cause (unwinder , PyExc_RuntimeError ,
99- "AsyncioDebug section unavailable - asyncio module may not be loaded in target process" );
95+ if (_Py_RemoteDebug_IsFatalReadError ()) {
96+ return -1 ;
97+ }
98+ PyErr_Clear ();
99+ /* Image discovery can fail without reporting that the target exited.
100+ Read a known runtime address before reporting unavailable asyncio. */
101+ char runtime_byte ;
102+ if (_Py_RemoteDebug_ReadRemoteMemory (& unwinder -> handle ,
103+ unwinder -> runtime_start_address , sizeof (runtime_byte ),
104+ & runtime_byte ) < 0 )
105+ {
106+ return -1 ;
100107 }
108+ PyErr_SetString (PyExc_RuntimeError , "AsyncioDebug section not available" );
109+ set_exception_cause (unwinder , PyExc_RuntimeError ,
110+ "AsyncioDebug section unavailable - asyncio module may not be loaded in target process" );
101111 return -1 ;
102112 }
103113
0 commit comments