libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
8.71k stars 1.64k forks source link

Crash at function Blit_3or4_to_3or4__same_rgb #9332

Open arnzel opened 3 months ago

arnzel commented 3 months ago

Hi i tried ton run some old dos game The Clou (https://github.com/vcosta/derclou) with jnr-ffi. This game use SDL libary for graphics and other functions (https://www.libsdl.org/) . I try to run this game with Java and the jnr-ffi library (https://github.com/jnr/jnr-ffi Java Abstracted Foreign Function Layer). But it seems to crash when invoking the function "Blit_3or4_to_3or4__same_rgb".

Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [libSDL2-2.0.0.dylib+0x86367] Blit_3or4_to_3or4__same_rgb+0x1ff C [libSDL2-2.0.0.dylib+0x6c4ac] SDL_SoftBlit+0x135 C [libSDL2-2.0.0.dylib+0xa0725] SDL_ConvertPixels_REAL+0x2b4 C [base.so+0x12651] gfxSetRGB+0x91 C [base.so+0x12012] gfxInit+0x6f2 C [base.so+0x8266] main+0x336

Exception Type: EXC_BAD_ACCESS (SIGABRT) Exception Codes: KERN_PROTECTION_FAILURE at 0x000000010927d128 Exception Codes: 0x0000000000000002, 0x000000010927d128

Maybe you can help me to understand where the problem can be. I have completely no idea if this is a problem of the JVM,jnr-ffi or the sdl library.

See also https://github.com/jnr/jnr-ffi/issues/344

slouken commented 3 months ago

SDL should never crash internally with valid input. What version of SDL are you using? Are you able to build a debug version of the latest release and try it with that?

1bsyl commented 3 months ago

you can force to use the slow_blit_function by modifying SDL https://github.com/libsdl-org/SDL/blob/main/src/video/SDL_blit.c#L280 (#define TEST_SLOW_BLIT 1) and see if this still crashes ...