Skip to content

Commit 157e946

Browse files
[3.14] pythongh-144194: Fix mmap failure check in perf_jit_trampoline.c (pythonGH-143713) (python#144301)
pythongh-144194: Fix mmap failure check in perf_jit_trampoline.c (pythonGH-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) Co-authored-by: stratakis <cstratak@redhat.com>
1 parent b82b12b commit 157e946

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
@@ -1054,7 +1054,8 @@ static void* perf_map_jit_init(void) {
10541054
0 // Offset 0 (first page)
10551055
);
10561056

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

0 commit comments

Comments
 (0)