Skip to content

Commit 40551ce

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 548526b commit 40551ce

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
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
@@ -1082,7 +1082,8 @@ static void* perf_map_jit_init(void) {
10821082
0 // Offset 0 (first page)
10831083
);
10841084

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

0 commit comments

Comments
 (0)