]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-144194: Fix mmap failure check in perf_jit_trampoline.c (#143713)
authorstratakis <cstratak@redhat.com>
Wed, 28 Jan 2026 13:30:17 +0000 (14:30 +0100)
committerGitHub <noreply@github.com>
Wed, 28 Jan 2026 13:30:17 +0000 (13:30 +0000)
mmap() returns MAP_FAILED ((void*)-1) on error, not NULL. The current
check never detects mmap failures, so jitdump initialization proceeds
even when the memory mapping fails.

Misc/NEWS.d/next/Core_and_Builtins/2026-01-23-20-20-42.gh-issue-144194.IbXfxd.rst [new file with mode: 0644]
Python/perf_jit_trampoline.c

diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-23-20-20-42.gh-issue-144194.IbXfxd.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-23-20-20-42.gh-issue-144194.IbXfxd.rst
new file mode 100644 (file)
index 0000000..1f33284
--- /dev/null
@@ -0,0 +1 @@
+Fix error handling in perf jitdump initialization on memory allocation failure.
index f51ab1b47a04f1d4db213e81164c70635445c881..0ba856ea610e5922aa78ed82c502e6f5f1cc5447 100644 (file)
@@ -1083,7 +1083,8 @@ static void* perf_map_jit_init(void) {
         0                        // Offset 0 (first page)
     );
 
-    if (perf_jit_map_state.mapped_buffer == NULL) {
+    if (perf_jit_map_state.mapped_buffer == MAP_FAILED) {
+        perf_jit_map_state.mapped_buffer = NULL;
         close(fd);
         return NULL;  // Memory mapping failed
     }