From 73711a35eaf92f040738c800e0f4b5566b5ada50 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 12 Dec 2025 13:13:18 +0100 Subject: [PATCH 1/2] gh-142627: Ignore anonymous mappings in Linux remote debugging --- Python/remote_debug.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Python/remote_debug.h b/Python/remote_debug.h index 1c02870d3af475..36248444f3b9c9 100644 --- a/Python/remote_debug.h +++ b/Python/remote_debug.h @@ -729,6 +729,11 @@ search_linux_map_for_section(proc_handle_t *handle, const char* secname, const c filename = path; // No directories, or an empty string } + if (filename[0] == '[' && filename[strlen(filename)-1] == ']') { + // Skip anonymous mapping: [heap], [anon:cpython:pymalloc], etc. + continue; + } + if (strstr(filename, substr)) { retval = search_elf_file_for_section(handle, secname, start, path); if (retval) { From 806c53a452fe7b9f95b67f4924c5dbd18ddfb200 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 12 Dec 2025 13:46:53 +0100 Subject: [PATCH 2/2] Move the check earlier --- Python/remote_debug.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Python/remote_debug.h b/Python/remote_debug.h index 36248444f3b9c9..d3932a3fd1e4d6 100644 --- a/Python/remote_debug.h +++ b/Python/remote_debug.h @@ -722,6 +722,11 @@ search_linux_map_for_section(proc_handle_t *handle, const char* secname, const c } const char *path = line + path_pos; + if (path[0] == '[' && path[strlen(path)-1] == ']') { + // Skip [heap], [stack], [anon:cpython:pymalloc], etc. + continue; + } + const char *filename = strrchr(path, '/'); if (filename) { filename++; // Move past the '/' @@ -729,11 +734,6 @@ search_linux_map_for_section(proc_handle_t *handle, const char* secname, const c filename = path; // No directories, or an empty string } - if (filename[0] == '[' && filename[strlen(filename)-1] == ']') { - // Skip anonymous mapping: [heap], [anon:cpython:pymalloc], etc. - continue; - } - if (strstr(filename, substr)) { retval = search_elf_file_for_section(handle, secname, start, path); if (retval) {