Opened 3 years ago

Closed 3 years ago

#7268 closed defect (fixed)

Mac crash on dead key keydown: When typing "~" in the search field on mac osx with i18n keyboard

Reported by: https://www.google.com/accounts/o8/id?id=aitoawlhvu-ww5nl-hcep6ztscfziak5ks67j6a Owned by: fkuehne
Priority: normal Milestone: 2.0.4
Component: Interface: Mac OS X Version: 2.0.3
Severity: normal Keywords:
Cc: Difficulty: unknown
Platform(s): MacOS Work status: Not started

Description

On Mac OS X 10.8, with my keyboard set to Norwegian, trying to type "~" in the search field in the main window crashes the app. On this keyboard layout, "~" is produced by holding Ctrl and then pressing the "¨" key.

It looks like the problem is that the keydown event produces an event where "charactersIgnoringModifiers" returns an empty (0-length) string. The following code does not verify the length before trying to access the first character:

http://git.videolan.org/gitweb.cgi/vlc.git/?p=vlc.git;a=blob;f=modules/gui/macosx/intf.m;h=0bcc263e038cad7109c946752a7d37480d580d71;hb=HEAD#l1353

and so VLC crashes with an NSRangeException.

Application Specific Information:
Crashing on exception: -[__NSCFString characterAtIndex:]: Range or index out of bounds

Application Specific Backtrace 1:
0   CoreFoundation                      0x00007fff8c20e716 __exceptionPreprocess + 198
1   libobjc.A.dylib                     0x00007fff8c9f5470 objc_exception_throw + 43
2   CoreFoundation                      0x00007fff8c20e4ec +[NSException raise:format:] + 204
3   CoreFoundation                      0x00007fff8c1d2ffe -[__NSCFString characterAtIndex:] + 94
4   libmacosx_plugin.dylib              0x00000001055b74d0 -[VLCMain hasDefinedShortcutKey:force:] + 208

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.AppKit              	0x00007fff8b896911 -[NSApplication _crashOnException:] + 106
1   com.apple.AppKit              	0x00007fff8b896c12 -[NSApplication _showException:] + 690
2   com.apple.AppKit              	0x00007fff8b63fd42 -[NSApplication run] + 836
3   libmacosx_plugin.dylib        	0x00000001055b39ae Run + 206
4   libvlccore.5.dylib            	0x0000000100039932 intf_Create + 770
5   libvlccore.5.dylib            	0x000000010002bb47 libvlc_InternalAddIntf + 215
6   libvlc.5.dylib                	0x000000010000814f libvlc_add_intf + 15
7   org.videolan.vlc              	0x0000000100002a97 main + 455
8   org.videolan.vlc              	0x00000001000028a4 start + 52

Trying to run "/Applications/VLC.app/Contents/MacOS/VLC -- -NSTraceEvents YES" shows:

2012-08-03 09:55:49.932 VLC[6539:707] Received event: KeyDown at: 714.0,184.0 time: 14659180603000 flags: 0x40101 win: 0 ctxt: 1e297 data: 0,252,126,30,168
2012-08-03 09:55:49.933 VLC[6539:707]     In Application: NSEvent: type=KeyDown loc=(0,490) time=14659.2 flags=0x40101 win=0x0 winNum=1001 ctxt=0x0 chars="~" unmodchars="" repeat=0 keyCode=30
2012-08-03 09:55:49.933 VLC[6539:707] -[__NSCFString characterAtIndex:]: Range or index out of bounds
2012-08-03 09:55:49.937 VLC[6539:707] (
	0   CoreFoundation                      0x00007fff8c20e716 __exceptionPreprocess + 198
	1   libobjc.A.dylib                     0x00007fff8c9f5470 objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff8c20e4ec +[NSException raise:format:] + 204
	3   CoreFoundation                      0x00007fff8c1d2ffe -[__NSCFString characterAtIndex:] + 94
	4   libmacosx_plugin.dylib              0x000000010572c4d0 -[VLCMain hasDefinedShortcutKey:force:] + 208
)

Change History (5)

comment:1 Changed 3 years ago by fkuehne

  • Milestone changed from Bugs paradize to 2.0.4
  • Status changed from new to assigned

Nice catch!

and thanks for the detailed report!

comment:2 Changed 3 years ago by https://www.google.com/accounts/o8/id?id=aitoawlhvu-ww5nl-hcep6ztscfziak5ks67j6a

Sure! :)

I wonder if they did something to these events/layouts in 10.8. Even Terminal.app crashes in a similar fashion, which is frustrating to say the least, since "~" is kind of essential to working on the shell.

10.7.4 used to be fine.

comment:3 Changed 3 years ago by fkuehne

Terminal.app crashes? Nice! :D I'm using the highly recommendable iTerm2, so wasn't aware of this.

As you'll see in a few minutes, your issue should be fixed by my latest commit!

comment:4 Changed 3 years ago by https://www.google.com/accounts/o8/id?id=aitoawlhvu-ww5nl-hcep6ztscfziak5ks67j6a

Quick and thorough, thanks a lot! :)

Good idea, maybe I should reconsider iTerm2 at least here on 10.8.0. :) Thanks :)

comment:5 Changed 3 years ago by fkuehne@…

  • Resolution set to fixed
  • Status changed from assigned to closed

commit c97faddc527a0455c93419982b23763a3d6485d8 Author: Felix Paul Kühne <fkuehne@…> Date: Fri Aug 3 14:37:34 2012 +0200

macosx: fixed NSRangeException when triggering modifier keys without characters as enabled by some international keyboards (close #7268)

Note: See TracTickets for help on using tickets.