]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-144194: Fix mmap failure check in perf_jit_trampoline.c (#143713) (#144304)
authorVictor Stinner <vstinner@python.org>
Wed, 28 Jan 2026 14:15:39 +0000 (15:15 +0100)
committerGitHub <noreply@github.com>
Wed, 28 Jan 2026 14:15:39 +0000 (14:15 +0000)
gh-144194: Fix mmap failure check in perf_jit_trampoline.c (#143713)

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.

(cherry picked from commit 8fe8a94a7c050bc16cac9ec300f89c0f389f9a44)

Co-authored-by: stratakis <cstratak@redhat.com>
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 3a63dd73bc47cca46168efdd546cb50b692afb98..b03da66e92e82526c372d2d3f46e182921c09fe4 100644 (file)
@@ -1053,7 +1053,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
     }