Skip to content

Commit 45651a9

Browse files
committed
gh-144194: 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.
1 parent 58ccf21 commit 45651a9

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix mmap failure check in perf jitdump initialization. The code incorrectly
2+
checked for NULL instead of MAP_FAILED, causing failures to go undetected.

Python/perf_jit_trampoline.c

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

1086-
if (perf_jit_map_state.mapped_buffer == NULL) {
1086+
if (perf_jit_map_state.mapped_buffer == MAP_FAILED) {
1087+
perf_jit_map_state.mapped_buffer = NULL;
10871088
close(fd);
10881089
return NULL; // Memory mapping failed
10891090
}

0 commit comments

Comments
 (0)