Jakz / retro8

PICO-8 implementation with SDL2/SDL1.2 and RetroArch back-ends
GNU General Public License v3.0
250 stars 30 forks source link

[Libretro] Celeste crashes when reaching the 1200m screen #35

Closed bslenul closed 2 years ago

bslenul commented 2 years ago

Hey!

The issue doesn't happen upstream but I'm posting here since issues aren't opened on the Libretro repo, I hope this is fine!

Celeste crashes with the Libretro core when reaching the 1200m screen, this one:

image

Bisected already and it started with https://github.com/libretro/retro8/commit/f128a4d121a0a9264ccd82e2d072f87bbc44b02f , so I guess I should ping @phcoder about this.

I have no idea if it happens in other games, I've only tried Celeste so far.

No idea if it helps but here's the GDB output:

Thread 1 received signal SIGFPE, Arithmetic exception.
0x00007ffbffc389aa in retro8::sfx::DSP::noise (this=0x1615ad65d48,
    frequency=164, amplitude=0, position=25800, dest=0x1615ad1e2b6,
    samples=660) at src/vm/sound.cpp:141
141         dest[i] += lfsr_state % amplitude - (amplitude / 2);
(gdb) bt full
#0  0x00007ffbffc389aa in retro8::sfx::DSP::noise (this=0x1615ad65d48,
    frequency=164, amplitude=0, position=25800, dest=0x1615ad1e2b6,
    samples=660) at src/vm/sound.cpp:141
        i = 0
        lfsr_state = 3669164065
        polytable = "\000\001\002\003\005\004\a\006\v\n\t\b\016\017\f\r\006\a\004\005\003\002\001\000\r\f\017\016\b\t\n\v\f\r\016\017\t\b\v\n\a\006\005\004\002\003\000\001\n\v\b\t\017\016\r\f\001\000\003\002\004\005\006\a\b\t\n\v\r\f\017\016\003\002\001\000\006\a\004\005\016\017\f\r\v\n\t\b\005\004\a\006\000\001\002\003\004\005\006\a\001\000\003\002\017\016\r\f\n\v\b\t\002\003\000\001\a\006\005\004\t\b\v\n\f\r\016\017\000\001\002\003\005\004\a\006\v\n\t\b\016\017\f\r\006\a\004\005\003\002\001\000\r\f\017\016\b\t\n\v\f\r\016\017\t\b\v\n\a\006\005\004\002\003\000\001\n\v\b\t\017\016\r\f\001\000\003\002\004\005\006\a\b\t\n\v\r\f\017\016"...
#1  0x00007ffbffc1e1b8 in retro8::sfx::APU::renderSound (this=0x1615ad65d40,
    channel=..., buffer=0x1615ad1e2b6, samples=660) at src/vm/sound.cpp:399
        sample = @0x1615ad6103e: {static EffectMask = 28672,
          static VolumeMask = 3584, static WaveformMask = 448,
          static PitchMask = 63, static EffectShift = 12,
          static VolumeShift = 9, static WaveformShift = 6, value = 400}
        maxVolume = 4096
        volume = 0
        frequency = 164
#2  0x00007ffbffc1e36c in retro8::sfx::APU::renderSounds (this=0x1615ad65d40,
    dest=0x1615ad1e220, totalSamples=735) at src/vm/sound.cpp:429
        available = 660
        samplePerTick = 1032
        buffer = 0x1615ad1e2b6
        samples = 660
        channel = @0x1615ad65de0: {sound = 0x1615ad6100c, soundIndex = 0,
          sample = 25, position = 25800, end = 31}
        music = 0x1615ad60eb8
        i = 2
#3  0x00007ffbffc16925 in retro_run () at src/libretro/libretro.cpp:349
        audioBuffer2 = 0x1615ad33aa8
#4  0x00007ff72dd74049 in core_run ()
No symbol table info available.
#5  0x00007ff72dd76535 in runloop_iterate ()
No symbol table info available.
#6  0x00007ff72dd6abe8 in rarch_main ()
No symbol table info available.
#7  0x00007ff72e4b62fa in main_getcmdline ()
No symbol table info available.
#8  0x00007ff72dd613c1 in __tmainCRTStartup ()
    at C:/_/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:321
        lock_free = <optimized out>
        fiberid = <optimized out>
        nested = <optimized out>
        lpszCommandLine = <optimized out>
        StartupInfo = {cb = 104, lpReserved = 0x161591e16f0 "",
          lpDesktop = 0x161591e15a0 "Winsta0\\Default",
          lpTitle = 0x161591b62e0 "G:\\msys64\\home\\B-S\\build\\retroarch.exe", dwX = 0, dwY = 0, dwXSize = 0, dwYSize = 0, dwXCountChars = 0,
          dwYCountChars = 0, dwFillAttribute = 0, dwFlags = 0,
          wShowWindow = 0, cbReserved2 = 0, lpReserved2 = 0x0,
          hStdInput = 0xffffffffffffffff, hStdOutput = 0xffffffffffffffff,
          hStdError = 0xffffffffffffffff}
        inDoubleQuote = <optimized out>
#9  0x00007ff72dd614d6 in WinMainCRTStartup ()
    at C:/_/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:176
        ret = 255

Happening on Windows 10 and my Linux Mint VM, haven't tried on any other devices.

phcoder commented 2 years ago

I see where it crashes. Thank you for crash dump. I'll make a patch today

phcoder commented 2 years ago

Can you test https://github.com/libretro/retro8/pull/13 ?

bslenul commented 2 years ago

image

Yup all good now, I was able to finish the game without any crash, thank you for the quick fix! 👍

bslenul commented 2 years ago

Fix got merged, closing! Thank you again for the fix! ❤️