libsdl-org / sdl12-compat

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

tatan: segfault on startup #264

Closed smcv closed 1 year ago

smcv commented 1 year ago

Prerequisites:

To reproduce:

Expected result: it runs

Actual result: Real SDL 1.2 works, sdl12-compat segfaults.

Thread 1 (Thread 0x7f8005f68740 (LWP 24401)):
#0  0x00007f80073b53c4 in Blit_3or4_to_3or4__same_rgb (info=<optimized out>) at ./src/video/SDL_blit_N.c:3129
#1  0x00007f800739b216 in SDL_SoftBlit (src=0x56287a2045f0, srcrect=0x7ffd85ea3fa0, dst=0x56287a103620, dstrect=0x7ffd85ea3f90) at ./src/video/SDL_blit.c:88
#2  0x00007f80073d0a59 in SDL_UpperBlit_REAL (src=0x56287a2045f0, srcrect=<optimized out>, dst=0x56287a103620, dstrect=0x7ffd85ea3f90) at ./src/video/SDL_surface.c:807
#3  0x00007f800880f62c in SDL_UpperBlit (src12=0x56287a2c9fc0, srcrect12=<optimized out>, dst12=0x56287a03a200, dstrect12=0x0) at /home/desktop/tmp/sdl12-compat/src/SDL12_compat.c:4772
#4  0x000056287805e30e in SDL_BlitSurface (dstrect=0x0, dst=<optimized out>, srcrect=0x0, src=<optimized out>) at import/SDL_video.d:712
#5  _D2br11gamemanager12InTitleState4drawMFZv (this=<optimized out>) at src/br/gamemanager.d:508
#6  0x000056287805295f in _D2br8mainloop8Mainloop4loopMFZv (this=0x7f8005e66000) at src/br/mainloop.d:174
#7  0x000056287806e97f in _D2br4boot10user_startFZi () at src/br/boot.d:62
#8  0x00007f800836dcf3 in __lambda2 (__capture=__capture@entry=0x7ffd85ea4220) at ../../../../src/libphobos/libdruntime/rt/dmain2.d:506
#9  0x00007f800836e365 in tryExec (dg=..., __capture=0x7ffd85ea4220) at ../../../../src/libphobos/libdruntime/rt/dmain2.d:467
#10 runAll (__capture=__capture@entry=0x7ffd85ea4220) at ../../../../src/libphobos/libdruntime/rt/dmain2.d:506
#11 0x00007f800836e524 in tryExec (dg=..., __capture=0x7ffd85ea4220) at ../../../../src/libphobos/libdruntime/rt/dmain2.d:467
#12 _d_run_main2 (args=..., totalArgsLength=totalArgsLength@entry=5, mainFunc=mainFunc@entry=0x56287806e990 <_Dmain>) at ../../../../src/libphobos/libdruntime/rt/dmain2.d:526
#13 0x00007f800836e677 in _d_run_main (argc=1, argv=<optimized out>, mainFunc=0x56287806e990 <_Dmain>) at ../../../../src/libphobos/libdruntime/rt/dmain2.d:318
#14 0x00007f8007a2920a in __libc_start_call_main (main=main@entry=0x56287804cca0 <main>, argc=argc@entry=1, argv=argv@entry=0x7ffd85ea4408) at ../sysdeps/nptl/libc_start_call_main.h:58
#15 0x00007f8007a292bc in __libc_start_main_impl (main=0x56287804cca0 <main>, argc=1, argv=0x7ffd85ea4408, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffd85ea43f8) at ../csu/libc-start.c:389
#16 0x000056287804ccda in _start ()
icculus commented 1 year ago

oh wow, this game is written in D, which explains the weird stack trace.

icculus commented 1 year ago

So it's calling SDL_UpperBlit with a destination surface with a NULL pixels field, which upsets SDL2...but it also has a clip rect of [0,0,0,0], which SDL 1.2 sees as being a no-op and returns without doing any further work, so we'll do that too.

icculus commented 1 year ago

Actually, SDL2 does all that logic too, so we'll just check for the NULL pixels and let the system sort out clipping, etc.

smcv commented 1 year ago

Confirmed fixed with https://github.com/libsdl-org/sdl12-compat/commit/67f8b3a85b782eefb4db90f34d5b0742ef2cb5fc, 1.2.58 + 29 commits