From c16b8f63f127d1d5d8cb8598e45ded57d9f432f2 Mon Sep 17 00:00:00 2001 From: Zhijin Zeng Date: Fri, 12 Jun 2026 23:03:07 +0800 Subject: [PATCH] [CORE] Change mmap flag judgment in getMmapped Change getMmapped to strictly check MEM_MMAP flag instead of MEM_ALLOCATED bitmask. --- src/custommem.c | 7 ++++++- src/include/custommem.h | 1 + src/libtools/signals.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/custommem.c b/src/custommem.c index 46e2ddc645..3309673633 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -2851,7 +2851,12 @@ uint32_t getProtection_fast(uintptr_t addr) int getMmapped(uintptr_t addr) { - return (rb_get(mapallmem, addr)&MEM_ALLOCATED); // will be ok for both MEM_ALLOCATED & MEM_MMAP + return (rb_get(mapallmem, addr)&MEM_MMAP) == MEM_MMAP; +} + +int getMAllocated(uintptr_t addr) +{ + return (rb_get(mapallmem, addr)&MEM_ALLOCATED); } int memExist(uintptr_t addr) diff --git a/src/include/custommem.h b/src/include/custommem.h index 48fcb42d05..1aa4d42141 100644 --- a/src/include/custommem.h +++ b/src/include/custommem.h @@ -121,6 +121,7 @@ void refreshProtection(uintptr_t addr); uint32_t getProtection(uintptr_t addr); uint32_t getProtection_fast(uintptr_t addr); int getMmapped(uintptr_t addr); +int getMAllocated(uintptr_t addr); int memExist(uintptr_t addr); void loadProtectionFromMap(void); #ifdef DYNAREC diff --git a/src/libtools/signals.c b/src/libtools/signals.c index 18a4000a2a..94c78e8298 100644 --- a/src/libtools/signals.c +++ b/src/libtools/signals.c @@ -939,7 +939,7 @@ void my_box64signalhandler(int32_t sig, siginfo_t* info, void * ucntx) #ifdef BAD_SIGNAL // try to see if the si_code makes sense // the RK3588 tend to need a special Kernel that seems to have a weird behaviour sometimes - if((sig==X64_SIGSEGV) && (addr) && (info->si_code == 1) && getMmapped((uintptr_t)addr)) { + if((sig==X64_SIGSEGV) && (addr) && (info->si_code == 1) && getMAllocated((uintptr_t)addr)) { printf_log(LOG_DEBUG, "Workaround for suspicious si_code for %p / prot=0x%hhx\n", addr, prot); info->si_code = 2; }