libretro / bsnes-mercury

Fork of bsnes with various performance improvements.
GNU General Public License v3.0
47 stars 39 forks source link

Loading Super Mario RPG with achievements enabled causes RetroArch to crash #87

Open Jamiras opened 3 years ago

Jamiras commented 3 years ago

This is caused by a memory descriptor providing an invalid pointer, so when the achievement code tries to read the associated memory, an invalid memory access exception occurs.

You can see this in the log just before the crash:

[INFO] [MEM] Registered 0x20000 bytes of SYSTEM RAM at $000000 (descriptor 5, offset 0x000000)
[INFO] [MEM] Registered 0x20000 bytes of SRAM at $020000 (descriptor 19, offset 0x3E0000)

The problem is descriptor 19's ptr is set to something that is clearly not a valid address.

image

When loading other games, the bad descriptor doesn't exist, so the SRAM segment just cannot be mapped. Here's the log from loading Super Mario All-Stars:

[INFO] [MEM] Registered 0x20000 bytes of SYSTEM RAM at $000000 (descriptor 5, offset 0x000000)
[INFO] [MEM] Could not map region starting at $020000
[INFO] [MEM] Registered 0x20000 bytes of SRAM at $020000 (null filler)

In this case, since the region specifically could not be mapped, the achievement code ignores it.

Radon86222 commented 2 years ago

I also observed this with Super Mario RPG as you did, as well as with Kirby Super Star and Kirby's Dream Land 3 (Both USA). Upon startup (roughly 2 seconds after startup for Super Star), immediate segfault. Disabling achievements fixes both. Not sure if it is exactly the same issue as yours, however.

If this matters, this also happens to me on Retroarch's regular bsnes core.