We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1056 - Frequent crashes in Touch events by simply touching the screen (currently in iPhone Simulator)
Summary: Frequent crashes in Touch events by simply touching the screen (currently in ...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.0
Hardware: iPhone/iPod touch iOS 3
: P2 critical
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-21 06:41 UTC by Pavel Kanzelsberger
Modified: 2011-01-28 10:22 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel Kanzelsberger 2010-09-21 06:41:30 UTC
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
Comment 1 Joseba García Echebarria 2010-12-15 01:55:22 UTC
I believe the crash is caused by a check not being performed on wether an SDL_Touch element is NULL before using it in the SDL_SendTouchMotion function in src/events/SDL_touch.c around line 400.
Judging from the rest of the code, there's a missing

    if (!touch) {
        return 0;
    }

before using "touch" as SDL_GetFinger(), SDL_GetFingerIndexId() use touch->num_fingers without checking.

I can attach a patch if you like. It seems pretty straightforward, though.

I have yet to discover why touch is being returned as NULL as this error is only triggered when an actual gesture has been performed, maybe something related to SDL_AddTouch()?

If it serves of any help I'm compiling from standard Makefile's, not from XCode. The "Touch" and "Fireworks" demos in the repository seem to be working fine when compiled from Xcode.
I will try to compile those examples with my Makefile to see if missing compilation flags are to be blamed for this.
Comment 2 Joseba García Echebarria 2010-12-17 03:41:14 UTC
As additional info, this was happening in iOS 4.2 too, the additional check fixes the crash.
Comment 3 Sam Lantinga 2011-01-28 10:22:44 UTC
This is fixed in the repository, thanks!