-
-
Notifications
You must be signed in to change notification settings - Fork 416
Description
I'm trying to run appimagetool-x86_64.AppImage and it crashes right away on ppc64le but runs fine on ARM64. The crash happens consistently at the same memory address.
After tracing through the execution with strace and gdb, I found something interesting:
mmap(0x38c70000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x38c70000
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_ACCERR, si_addr=0x38c71000} ---
The AppImage maps a 4KB region as PROT_NONE, then immediately tries to access the next 4KB page (0x38c71000). This works fine on ARM64 with 4KB pages, but fails on ppc64le with 64KB pages.
I think this is because static binaries like AppImages assume they can allocate small chunks and access adjacent memory, which works on 4KB page systems but breaks on 64KB page systems.
I added some compatibility handling specifically for ppc64le in src/custommem.c. When I detect small PROT_NONE mappings (which seem to be how these static allocators work), I map them as PROT_READ|PROT_WRITE instead, but only on ppc64le:
#ifdef PPC64LE
// Handle static binary compatibility on 64KB page systems
if (prot == PROT_NONE && size <= 0x10000) {
if (trace_mmap) {
printf_log(LOG_DEBUG, "[BOX64] PPC64LE: Mapping 0x%lx bytes as RW instead of NONE for compatibility at %p\n", size, addr);
}
prot = PROT_READ | PROT_WRITE;
}
#endifThe fix only activates on ppc64le, so there's no impact on the ARM64, RV64, LA64 backend.
Are there any concerns with mapping PROT_NONE as RW for small allocations?
Would you be interested in a PR for this? I have the complete fix working on my systems.
My setup:
- ppc64le: POWER9, 64KB pages, Linux 6.8
- ARM64: aarch64, 4KB pages, Linux 6.8
- Test binary: appimagetool-x86_64.AppImage
Let me know what you think! I'm happy to provide more details or adjust the approach if needed.