E4E7 gh-144194: Fix mmap failure check in perf_jit_trampoline.c · python/cpython@55402f6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 55402f6

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 55402f6

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
@@ -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)
0