From 3adf31c85b8bb4366d063fbe8f7d9fc36084366d Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 16 Apr 2023 10:50:12 +0200 Subject: [DYNAREC] General fixes and improvment for multithread and jit program. Helps Java, mono and Unity3d program... (should help #519, #464, #433, #272, #232, #193, #112...) --- src/libtools/signals.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/libtools') diff --git a/src/libtools/signals.c b/src/libtools/signals.c index 3e9bbce5..263711f2 100755 --- 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) } // access error, unprotect the block (and mark them dirty) unprotectDB((uintptr_t)addr, 1, 1); // unprotect 1 byte... But then, the whole page will be unprotected - if(db && ((addr>=db->x64_addr && addr<(db->x64_addr+db->x64_size)) || db->need_test)) { + if(db && ((addr>=db->x64_addr && addr<(db->x64_addr+db->x64_size)) || getNeedTest((uintptr_t)db->x64_addr))) { // dynablock got auto-dirty! need to get out of it!!! emu_jmpbuf_t* ejb = GetJmpBuf(); if(ejb->jmpbuf_ok) { @@ -998,6 +998,8 @@ void my_box64signalhandler(int32_t sig, siginfo_t* info, void * ucntx) if(db && db->x64_addr>= addr && (db->x64_addr+db->x64_size)si_code==2 && ((prot&~PROT_DYN)==5 || (prot&~PROT_DYN)==7)) { + if((sig==SIGSEGV) && (info->si_code == SEGV_ACCERR) && ((prot&~PROT_CUSTOM)==5 || (prot&~PROT_CUSTOM)==7)) { static uintptr_t old_addr = 0; printf_log(/*LOG_DEBUG*/LOG_INFO, "Strange SIGSEGV with Access error on %p for %p, db=%p, prot=0x%x (old_addr=%p)\n", pc, addr, db, prot, (void*)old_addr); - if(old_addr!=(uintptr_t)addr) { + #ifdef DYNAREC + cleanDBFromAddressRange(((uintptr_t)addr)&~(box64_pagesize-1), box64_pagesize, 0); + #endif + if(old_addr!=(uintptr_t)addr || getMmapped((uintptr_t)addr)) { old_addr = (uintptr_t)addr; refreshProtection(old_addr); relockMutex(Locks); @@ -1222,7 +1227,7 @@ exit(-1); prot, db, db?db->block:0, db?(db->block+db->size):0, db?db->x64_addr:0, db?(db->x64_addr+db->x64_size):0, getAddrFunctionName((uintptr_t)(db?db->x64_addr:0)), - (db?db->need_test:0)?"need_stest":"clean", db?db->hash:0, hash, + (db?getNeedTest((uintptr_t)db->x64_addr):0)?"need_stest":"clean", db?db->hash:0, hash, (void*)my_context->signals[sig]); #if defined(ARM64) if(db) { -- cgit 1.4.1