libretro / picodrive

Fast MegaDrive/MegaCD/32X emulator
Other
38 stars 60 forks source link

32x Dynarec crash on Cyber Brawl ~ Cosmic Carnage #159

Closed Sanaki closed 3 years ago

Sanaki commented 3 years ago

As the title suggests, when playing the 32x game Cyber Brawl ~ Cosmic Carnage (Japan, USA), after some time (a couple rounds) RetroArch will just exit with a log message of "recompilation failed". No segfault or abort, it exits cleanly.

irixxxx commented 3 years ago

If you are able to compile your own core, would you please increase the insn_count multiplier in line 1254 of cpu/sh2/compiler.c to, say, 160, and try again? Forget that. There seems to be a memory corruption when writing to the drc cache.

irixxxx commented 3 years ago

Could you please apply this patch to cpu/sh2/compiler.c and see if the problem goes away?

@@ -1069,7 +1069,6 @@ static void dr_rm_block_entry(struct block_desc *bd, int tcache_id, u32 nolit, i
     rm_from_block_lists(bd);
     bd->addr = bd->size = bd->addr_lit = bd->size_lit = 0;
     bd->entry_count = 0;
-    bd->entryp = NULL;
   }
   emith_update_cache();
Sanaki commented 3 years ago

Given the delayed and apparently random nature of the crash, it's possible I'm just missing it by luck, but removing that one line did indeed appear to stop the crashes.

irixxxx commented 3 years ago

I discovered something similar is also happening if you let the demo mode run for some time into its 3rd round. That is fixed by this. It's a bug in the buffer management - the value of that pointer (not the data it points to) is needed in case of the removal of code buffers due to a code cache overflow.

irixxxx commented 3 years ago

fixed by 6f9993a in my repo, fixed in this repo with the next merge.

irixxxx commented 3 years ago

Merged.