Skip to content

Commit d7ed964

Browse files
stratakisvstinner
authored andcommitted
pythongh-144194: Fix mmap failure check in perf_jit_trampoline.c (python#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 8fe8a94)
1 parent bc92e78 commit d7ed964

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix error handling in perf jitdump initialization on memory allocation failure.

Python/perf_jit_trampoline.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,8 @@ static void* perf_map_jit_init(void) {
10531053
0 // Offset 0 (first page)
10541054
);
10551055

1056-
if (perf_jit_map_state.mapped_buffer == NULL) {
1056+
if (perf_jit_map_state.mapped_buffer == MAP_FAILED) {
1057+
perf_jit_map_state.mapped_buffer = NULL;
10571058
close(fd);
10581059
return NULL; // Memory mapping failed
10591060
}

0 commit comments

Comments
 (0)