https://github.com/python/cpython/commit/e752ea9eb9795fac7a26d268f67ab5ad416c92b4
commit: e752ea9eb9795fac7a26d268f67ab5ad416c92b4
branch: 3.13
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-01-28T14:15:39Z
summary:

[3.13] gh-144194: Fix mmap failure check in perf_jit_trampoline.c (#143713) 
(#144304)

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 <[email protected]>

files:
A Misc/NEWS.d/next/Core and 
Builtins/2026-01-23-20-20-42.gh-issue-144194.IbXfxd.rst
M 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
index 00000000000000..1f33284439c041
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and 
Builtins/2026-01-23-20-20-42.gh-issue-144194.IbXfxd.rst 
@@ -0,0 +1 @@
+Fix error handling in perf jitdump initialization on memory allocation failure.
diff --git a/Python/perf_jit_trampoline.c b/Python/perf_jit_trampoline.c
index 3a63dd73bc47cc..b03da66e92e825 100644
--- a/Python/perf_jit_trampoline.c
+++ b/Python/perf_jit_trampoline.c
@@ -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
     }

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to