SDL 1.3 crashing on iPhone

Hello,

just to let you know I just reported quite frequent crashing of SDL 1.3 on iPhone Simulator in Touch interface, it happens quite often by simply tapping on display…

http://bugzilla.libsdl.org/show_bug.cgi?id=1056

Here’s output from GDB:

Program received signal: ?EXC_BAD_ACCESS?.
(gdb) bt
#0 0x000e995b in SDL_GetFingerIndexId (touch=0x0, fingerid=97068992) at /Users/pavel/Sources/SDL/Xcode-iPhoneOS/SDL/…/…/src/events/SDL_touch.c:67
#1 0x000e999a in SDL_GetFinger (touch=0x0, id=97068992) at /Users/pavel/Sources/SDL/Xcode-iPhoneOS/SDL/…/…/src/events/SDL_touch.c:77
#2 0x000ea41b in SDL_SendTouchMotion (id=1, fingerid=97068992, relative=0, xin=181, yin=158, pressurein=1) at /Users/pavel/Sources/SDL/Xcode-iPhoneOS/SDL/…/…/src/events/SDL_touch.c:400
#3 0x000c2f0c in -[SDL_uikitview touchesMoved:withEvent:] (self=0x5c5ed70, _cmd=0x221dc6c, touches=0x70830e0, event=0x5c16020) at /Users/pavel/Sources/SDL/Xcode-iPhoneOS/SDL/…/…/src/video/uikit/SDL_uikitview.m:190
#4 0x008ca2a9 in -[UIWindow _sendTouchesForEvent:] ()
#5 0x008ac1ec in -[UIApplication sendEvent:] ()
#6 0x008b0ac4 in _UIApplicationHandleEvent ()
#7 0x03e43afa in PurpleEventCallback ()
#8 0x029f2dc4 in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION ()
#9 0x02953737 in __CFRunLoopDoSource1 ()
#10 0x029509c3 in __CFRunLoopRun ()
#11 0x02950280 in CFRunLoopRunSpecific ()
#12 0x029501a1 in CFRunLoopRunInMode ()
#13 0x000c1f6b in UIKit_PumpEvents (_this=0x6041200) at /Users/pavel/Sources/SDL/Xcode-iPhoneOS/SDL/…/…/src/video/uikit/SDL_uikitevents.m:51
#14 0x0006ffff in SDL_PumpEvents () at /Users/pavel/Sources/SDL/Xcode-iPhoneOS/SDL/…/…/src/events/SDL_events.c:434
#15 0x0007006e in SDL_WaitEventTimeout (event=0xbfffdc60, timeout=-1) at /Users/pavel/Sources/SDL/Xcode-iPhoneOS/SDL/…/…/src/events/SDL_events.c:468
#16 0x00070047 in SDL_WaitEvent (event=0xbfffdc60) at /Users/pavel/Sources/SDL/Xcode-iPhoneOS/SDL/…/…/src/events/SDL_events.c:456
#17 0x00008267 in GUI_MAINLOOP (POLL=false, CALLBACKS=false) at gui.s:2771
#18 0x000120a3 in GUI_LAYOUTDEFAULTCALLBACK_MOUSEBUTTON (LAYOUT=0xdd56420, OBJ=0x0, TAB=-1, X=171, Y=7, BUTTONS=1) at gui.s:25161
#19 0x0001158b in GUI_LAYOUTMOUSEBUTTONDOWN (LAYOUT=0xdd56420, X=181, Y=157, BUTTONS=1) at gui.s:23671
#20 0x0000839e in GUI_MAINLOOP (POLL=false, CALLBACKS=4294967295) at gui.s:2866
#21 0x00008c47 in GUI_RUNAPP () at gui.s:3563
#22 0x00006776 in APPSTART () at PascalLibrary.s:5227
#23 0x0000251f in SDL_main (argc=1, argv=0x5c0f680) at /Users/pavel/Projects/iPhone/iPhoneEAGL/main.m:14
#24 0x000c44cf in -[SDLUIKitDelegate postFinishLaunch] (self=0x5c18530, _cmd=0x196850) at /Users/pavel/Sources/SDL/Xcode-iPhoneOS/SDL/…/…/src/video/uikit/SDL_uikitappdelegate.m:75
#25 0x0260dcea in __NSFireDelayedPerform ()
#26 0x029f2d43 in CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION ()
#27 0x029f4384 in __CFRunLoopDoTimer ()
#28 0x02950d09 in __CFRunLoopRun ()
#29 0x02950280 in CFRunLoopRunSpecific ()
#30 0x029501a1 in CFRunLoopRunInMode ()
#31 0x03e422c8 in GSEventRunModal ()
#32 0x03e4238d in GSEventRun ()
#33 0x008b4b58 in UIApplicationMain ()
#34 0x000c43d8 in main (argc=1, argv=0xbffff004) at /Users/pavel/Sources/SDL/Xcode-iPhoneOS/SDL/…/…/src/video/uikit/SDL_uikitappdelegate.m:53—
Pavel Kanzelsberger


E-Mail: pavel at kanzelsberger.com
Jabber: kanzelsberger at jabber.org, ICQ: 20990633

Hi,

As this is my first port, I’d like to thank all the developers for the work they’re doing with SDL, and in particular with 1.3. Looking really promising :slight_smile:

Second: sorry to bring up an old post, but I believe the cause of this to be in src/events/SDL_touch.c, in function SDL_SendTouchMotion(…)
I’d say that the line (400) that states:

Code:
SDL_Finger *finger = SDL_GetFinger(touch,fingerid);

should be moved below line 408 that checks whether touch is NULL, as SDL_GetFinger(…) calls SDL_GetFingerIndexId(…) which eventually performs a

Code:
for(i = 0;i < touch->num_fingers;i++)

When touch is NULL, the program crashes.

I posted a similar comment in the original bug description page, so sorry for double-posting if this has already been spotted.

Joseba

Sam, could you give this an eye? I believe that change fixes the crash and seems to be very easy to fix.

Thanks a lot :slight_smile:

I got your fix, thanks!On Mon, Jan 3, 2011 at 6:30 PM, josebagar <joseba.gar at gmail.com> wrote:

Hi,

As this is my first port, I’d like to thank all the developers for the work
they’re doing with SDL, and in particular with 1.3. Looking really promising
[image: Smile]

Second: sorry to bring up an old post, but I believe the cause of this to
be in src/events/SDL_touch.c, in function SDL_SendTouchMotion(…)
I’d say that the line (400) that states:

Code:

SDL_Finger *finger = SDL_GetFinger(touch,fingerid);

should be moved below line 408 that checks whether touch is NULL, as
SDL_GetFinger(…) calls SDL_GetFingerIndexId(…) which eventually performs
a

Code:

for(i = 0;i < touch->num_fingers;i++)

When touch is NULL, the program crashes.

I posted a similar comment in the original bug description page, so sorry
for double-posting if this has already been spotted.

Joseba


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

Thanks!