libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
191 stars 40 forks source link

[Cave Story Freeware] doukutsu.bin: Abort/segfault at startup (audio crash) #335

Closed FoxMcCloud45 closed 1 month ago

FoxMcCloud45 commented 1 month ago

Machine: Ubuntu Unity 22.04 LTS

The compatibility sheet lists Cave Story+ but not the freeware port (built from the original source code). Here's the link to the port's ZIP.

The game runs fine using the classic SDL 1.2 library but not using sdl12-compat.

On Ubuntu 22.04 LTS, it's possible to run doukutsu.bin by manually installing libsdl1.2debian, which is the classic SDL 1.2 library itself.
However, later distributions (including 23.10 and 24.04 LTS) replace it with SDL12-compat.

By building the classic SDL 1.2 library and replacing the obsolete one shipped with the game, the game runs.
However, if I build sdl12-compat and use that library instead, the game aborts at startup with a "corrupted double-linked list".

I built SDL2 as well to get debug symbols, then ran the game with Valgrind. I get segmentation faults.

Expand ``` ==69300== Memcheck, a memory error detector ==69300== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==69300== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info ==69300== Command: ./doukutsu.bin ==69300== ERROR: ld.so: object 'libgtk3-nocsd.so.0' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. INFO: sdl12-compat 1.2.69, built on May 31 2024 at 15:07:15, talking to SDL2 2.30.3 INFO: This app appears to be named 'doukutsu.bin' ==69300== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s) ==69300== at 0x42DBD01: sendmsg (sendmsg.c:30) ==69300== by 0x5710DF1: ??? (in /usr/lib/i386-linux-gnu/libxcb.so.1.1.0) ==69300== by 0x571199E: ??? (in /usr/lib/i386-linux-gnu/libxcb.so.1.1.0) ==69300== by 0x57126C2: xcb_flush (in /usr/lib/i386-linux-gnu/libxcb.so.1.1.0) ==69300== by 0x71A84B5: ??? (in /usr/lib/i386-linux-gnu/libGLX_nvidia.so.470.239.06) ==69300== by 0x71A86DB: ??? (in /usr/lib/i386-linux-gnu/libGLX_nvidia.so.470.239.06) ==69300== by 0x71A3BAF: ??? (in /usr/lib/i386-linux-gnu/libGLX_nvidia.so.470.239.06) ==69300== by 0x71A8276: ??? (in /usr/lib/i386-linux-gnu/libGLX_nvidia.so.470.239.06) ==69300== by 0x71435B9: ??? (in /usr/lib/i386-linux-gnu/libGLX_nvidia.so.470.239.06) ==69300== by 0x7143EA3: ??? (in /usr/lib/i386-linux-gnu/libGLX_nvidia.so.470.239.06) ==69300== by 0x19855755: ??? (in /usr/lib/i386-linux-gnu/libnvidia-glcore.so.470.239.06) ==69300== by 0x198561D6: ??? (in /usr/lib/i386-linux-gnu/libnvidia-glcore.so.470.239.06) ==69300== Address 0x442115d is 4,477 bytes inside a block of size 21,032 alloc'd ==69300== at 0x4048354: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-x86-linux.so) ==69300== by 0x5710935: xcb_connect_to_fd (in /usr/lib/i386-linux-gnu/libxcb.so.1.1.0) ==69300== by 0x5715B69: xcb_connect_to_display_with_auth_info (in /usr/lib/i386-linux-gnu/libxcb.so.1.1.0) ==69300== by 0x5715CF1: xcb_connect (in /usr/lib/i386-linux-gnu/libxcb.so.1.1.0) ==69300== by 0x55EB9DA: _XConnectXCB (in /usr/lib/i386-linux-gnu/libX11.so.6.4.0) ==69300== by 0x55DBAE5: XOpenDisplay (in /usr/lib/i386-linux-gnu/libX11.so.6.4.0) ==69300== by 0x49219EA: X11_CreateDevice (SDL_x11video.c:170) ==69300== by 0x48FE1D4: SDL_VideoInit_REAL (SDL_video.c:513) ==69300== by 0x480A2FE: SDL_InitSubSystem_REAL.part.0 (SDL.c:258) ==69300== by 0x4079572: SDL_InitSubSystem (in /home/fox/Documents/linuxDoukutsu-1.2/libSDL-1.2.so.0) ==69300== by 0x407961A: SDL_Init (in /home/fox/Documents/linuxDoukutsu-1.2/libSDL-1.2.so.0) ==69300== by 0x806918C: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== ==69300== Invalid write of size 4 ==69300== at 0x48182D7: SDL_ResampleAudio (SDL_audiocvt.c:256) ==69300== by 0x48182D7: SDL_ResampleCVT (SDL_audiocvt.c:527) ==69300== by 0x48182D7: SDL_ResampleCVT_c2 (SDL_audiocvt.c:549) ==69300== by 0x481964C: SDL_ConvertAudio_REAL (SDL_audiocvt.c:281) ==69300== by 0x4093BA4: SDL_ConvertAudio (in /home/fox/Documents/linuxDoukutsu-1.2/libSDL-1.2.so.0) ==69300== by 0x80C210E: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== by 0x8067F9D: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== by 0x8067B13: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== by 0x80695DA: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== by 0x41D8518: (below main) (libc_start_call_main.h:58) ==69300== Address 0x7eabd78 is 0 bytes after a block of size 40,000 alloc'd ==69300== at 0x40436A0: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-x86-linux.so) ==69300== by 0x80C2003: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== by 0x8067F9D: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== by 0x8067B13: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== by 0x80695DA: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== by 0x41D8518: (below main) (libc_start_call_main.h:58) ==69300== ==69300== ==69300== Process terminating with default action of signal 11 (SIGSEGV): dumping core ==69300== Bad permissions for mapped region at address 0x7EAE000 ==69300== at 0x48182D7: SDL_ResampleAudio (SDL_audiocvt.c:256) ==69300== by 0x48182D7: SDL_ResampleCVT (SDL_audiocvt.c:527) ==69300== by 0x48182D7: SDL_ResampleCVT_c2 (SDL_audiocvt.c:549) ==69300== by 0x481964C: SDL_ConvertAudio_REAL (SDL_audiocvt.c:281) ==69300== by 0x4093BA4: SDL_ConvertAudio (in /home/fox/Documents/linuxDoukutsu-1.2/libSDL-1.2.so.0) ==69300== by 0x80C210E: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== by 0x8067F9D: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== by 0x8067B13: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== by 0x80695DA: ??? (in /home/fox/Documents/linuxDoukutsu-1.2/doukutsu.bin) ==69300== by 0x41D8518: (below main) (libc_start_call_main.h:58) ==69300== ==69300== HEAP SUMMARY: ==69300== in use at exit: 17,676,055 bytes in 7,339 blocks ==69300== total heap usage: 49,597 allocs, 42,258 frees, 978,819,781 bytes allocated ==69300== ==69300== LEAK SUMMARY: ==69300== definitely lost: 5,596 bytes in 8 blocks ==69300== indirectly lost: 92,831 bytes in 784 blocks ==69300== possibly lost: 9,766,346 bytes in 77 blocks ==69300== still reachable: 7,811,282 bytes in 6,470 blocks ==69300== of which reachable via heuristic: ==69300== newarray : 8 bytes in 1 blocks ==69300== multipleinheritance: 64 bytes in 1 blocks ==69300== suppressed: 0 bytes in 0 blocks ==69300== Rerun with --leak-check=full to see details of leaked memory ==69300== ==69300== Use --track-origins=yes to see where uninitialised values come from ==69300== For lists of detected and suppressed errors, rerun with: -s ==69300== ERROR SUMMARY: 2211 errors from 2 contexts (suppressed: 0 from 0) Segmentation fault (core dumped) ```

This happens with all of the drivers I tested (pulseaudio (default), ALSA, disk).

I'm not an expert at SDL(2) so I'm not sure of what might be going wrong but I guess SDL_AudioConvert() needs investigation.

I'm attaching some more logs but I doubt they're very useful.

20240531-crash02.log 20240531-crash-alsa.log 20240531-crash-disk.log

FoxMcCloud45 commented 1 month ago

Okay so I only found out after opening the source code that:

SDL12COMPAT_COMPATIBILITY_AUDIOCVT=1

fixes the issue. So I suppose it can be added in the quirks array.