Hi,
I have reproduced the problem, now with SDL compiled from svn trunk,
revision 5555. this time with more symbols:
#0 0x00000001010f1338 in SDL_SendKeyboardKey (index=0, state=1 ‘\001’,
scancode=SDL_SCANCODE_LGUI) at src/events/SDL_keyboard.c:812
812 event.key.windowID = keyboard->focus->id;
(gdb)
(gdb) print keyboard
$1 = (SDL_Keyboard *) 0x10086b000
(gdb) print keyboard->focus
$2 = (SDL_Window *) 0x0
(gdb) bt
#0 0x00000001010f1338 in SDL_SendKeyboardKey (index=0, state=1 ‘\001’,
scancode=SDL_SCANCODE_LGUI) at src/events/SDL_keyboard.c:812
#1 0x0000000101147e51 in Cocoa_HandleKeyEvent (_this=<value temporarily
unavailable, due to optimizations>, event=<value temporarily unavailable,
due to optimizations>) at src/video/cocoa/SDL_cocoakeyboard.m:329
#2 0x0000000101146c1e in Cocoa_PumpEvents (_this=0x1003345b0) at
src/video/cocoa/SDL_cocoaevents.m:213
#3 0x00000001010f0175 in SDL_PumpEvents () at src/events/SDL_events.c:370
#4 0x00000001010f0585 in SDL_WaitEventTimeout (event=0x7fff5fbff830,
timeout=0) at src/events/SDL_events.c:404
as you can see from the GDB trace, the keyboard->focus is NULL and
being de-referenced.
Thank you for this investigation, the attached patch should fix the crash.
thanks, I already did that locally, and now it does not crash
However, that’s just part of the solution, because normally when a keyboard
event is received, it should always has a focused window (otherwise it won’t
be able to receive such event), so the problem is why you received this
event without any focused window. Probably there is a bug in window focus
handling, but I am not sure. Still, it will be helpful if you can send us
a minimal sample.
it might also be that I am using the SDL API in a wrong way, either
from different threads or similar…
I had a new crash, also caused by a NULL pointer deref:
#0 SDL_OnWindowFocusLost (window=0x1003583c0) at src/video/SDL_video.c:1427
1427 if (display->gamma && _this->SetDisplayGammaRamp) {
(gdb) print display
$1 = (SDL_VideoDisplay *) 0x0
(gdb) bt
#0 SDL_OnWindowFocusLost (window=0x1003583c0) at src/video/SDL_video.c:1427
#1 0x00000001010f2c1b in SDL_SendWindowEvent (window=0x1003583c0, windowevent=<value temporarily unavailable, due to optimizations>, data1=0, data2=0) at src/events/SDL_windowevents.c:141
#2 0x00000001010f15df in SDL_SetKeyboardFocus (index=0, window=0x101863480) at src/events/SDL_keyboard.c:672
#3 0x00007fff81b2a85a in _nsnote_callback ()
#4 0x00007fff85041e3a in __CFXNotificationPost ()
#5 0x00007fff8502e3e8 in _CFXNotificationPostNotification ()
#6 0x00007fff81b217c4 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#7 0x00007fff865f0254 in -[NSWindow becomeKeyWindow] ()
#8 0x00007fff8674c554 in _NXShowKeyAndMain ()
#9 0x00007fff8662824c in -[NSApplication sendEvent:] ()
#10 0x0000000101146c5f in Cocoa_PumpEvents (_this=0x100337660) at src/video/cocoa/SDL_cocoaevents.m:221
#11 0x00000001010f0175 in SDL_PumpEvents () at src/events/SDL_events.c:370
#12 0x00000001010f0585 in SDL_WaitEventTimeout (event=0x7fff5fbff830, timeout=0) at src/events/SDL_events.c:404
#13 0x00000001007cfe66 in event_handler (arg=0x0) at modules/sdl/sdl.c:140
(gdb) print _this
$2 = (SDL_VideoDevice *) 0x100337660
/alfredOn 2/25/10 3:08 AM, Jjgod Jiang wrote:
On Wed, Feb 24, 2010 at 6:09 PM, Alfred E. Heggestad<@Alfred_E_Heggestad> wrote: