From b1b2c3cc9f7ff907ad57456597a4bcc1c122f54e Mon Sep 17 00:00:00 2001 From: Charalampos Stratakis Date: Sun, 11 Jan 2026 23:36:01 +0100 Subject: [PATCH] Fix mmap failure check in perf_jit_trampoline.c 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. --- Python/perf_jit_trampoline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Python/perf_jit_trampoline.c b/Python/perf_jit_trampoline.c index 0ffa906d85cc6b..aee1028d5f87eb 100644 --- a/Python/perf_jit_trampoline.c +++ b/Python/perf_jit_trampoline.c @@ -1082,7 +1082,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 }