Tracker: Bugs

9 Entering circumflex '^' into entry crashes TkAqua 8.6b1.1 - ID: 2907388
Last Update: Comment added ( wordtech )

The following script:

% entry .e
% pack .e

will crash TkAqua8.6b1.1 when entering a circumflex (the ^ character) into the entry. This is true for both the i386 and the x86_64 builds. The error message is:

2009-12-02 11:17:30.936 wish-aqua8.6[6459:903] An uncaught exception was raised
2009-12-02 11:17:30.939 wish-aqua8.6[6459:903] *** -[NSCFString characterAtIndex:]: Range or index out of bounds
2009-12-02 11:17:31.023 wish-aqua8.6[6459:903] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFString characterAtIndex:]: Range or index out of bounds'
*** Call stack at first throw:
(
0 CoreFoundation 0x00007fff85879444 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff8496d0f3 objc_exception_throw + 45
2 CoreFoundation 0x00007fff85879267 +[NSException raise:format:arguments:] + 103
3 CoreFoundation 0x00007fff858791f4 +[NSException raise:format:] + 148
4 Foundation 0x00007fff801803d5 -[NSCFString characterAtIndex:] + 97
5 Tk 0x00000001000c52e0 Tk_SetCaretPos + 674
6 Tk 0x00000001000cb9db Tk_MacOSXSetupTkNotifier + 701
7 Tcl 0x00000001001f4486 Tcl_DoOneEvent + 297
8 Tk 0x000000010001d8e0 Tk_MainLoop + 24
9 Tk 0x000000010002b36a Tk_MainEx + 1491
10 wish-aqua8.6 0x000000010000548b 0x0 + 4294988939
11 wish-aqua8.6 0x00000001000053d0 0x0 + 4294988752
12 ??? 0x0000000000000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Abort trap


Torsten Berg ( treincke ) - 2009-12-02 02:25:16 PST

9

Closed

Accepted

Daniel A. Steffen

07. [entry]

obsolete: 8.6b1.1

Public


Comments ( 8 )

Date: 2011-01-24 07:25:13 PST
Sender: wordtech

I've committed Torsten's patch--thanks, Torsten. This works around the
issue by avoiding the crash, but I'm still not able to input some composite
characters (option-u, for instance): the keyboard input is ignored.
(Shift-option-u does work.)

Composite characters and Unicode are surprisingly difficult to manage in
Cocoa; I've spent a number of hours investigating this and was not able to
find any solution to the question. Torsten's patch is the only workable
solution for the moment.


Date: 2011-01-23 03:42:20 PST
Sender: treincke

I uploaded a patched version of the file tkMacOSXKeyEvent.c (patched from
cvs revision 1.30) that circumvents the bug by catching the condition that
causes the crash in [characterAtIndex].

This will let the character through, but not the accent used to make the
composed character.


Date: 2011-01-22 12:23:53 PST
Sender: neddeily

This is a really nasty bug and, with the release of Cocoa Tk backports to
Tk 8.5, as in the Tcl/Tk 8.5.7 shipped by Apple in Mac OS X 10.6 and the
recent ActiveState Tcl/Tk 8.5.9, it is impacting more applications and
users. In OS X 10.6, the Apple-supplied Python Tkinter modules and, thus,
IDLE are susceptible to this crash: /usr/bin/idle2.6 and, with the US
Extended input method, type Option-u (umlaut combiner) or Option-n (tilde
combiner), for instance. For the Python Software Foundation (python.org)
Python installers for OS X, we were intending to support 64-bit Python with
a recommendation to use the ActiveState 8.5.9 Tcl/Tk (since the
Apple-supplied one has so many other problems with Tkinter and IDLE) but
this easy crasher seems to be a show stopper for that
(http://bugs.python.org/issue10973). I see that postfix combining
characters (like Shift-Option-u) work without crashing. It also appears
that the system Character Viewer input does not work at all.

Any prognosis on a fix for this problem?


Date: 2010-11-15 14:01:59 PST
Sender: captsolo

As pointed out in comment from 2010-06-25, this crash happens for [all]
composite characters.

In my case, a Tkinter app crashed when entering accented Latvian character
using the ' (single quote) modifier key. Input locale on Mac OS X 10.6 was
set to Latvian.

Out of the two ways for entering the same accented character - using a
"sticky" single quote key followed by the letter char or pressing Opt-
together with the letter char - the former causes the crash while the
latter shows the correct character. This confirms that the crash is caused
by the "sticky" modifier key and not by the accented character itself.


Date: 2010-07-04 16:18:43 PDT
Sender: dkf

It's the composing circumflex (Option-i) that causes trouble.


Date: 2010-07-02 06:10:15 PDT
Sender: treincke

This seems to be related to this discussion:

http://www.cocoabuilder.com/archive/cocoa/181364-characteratindex-method-and-composite-characters.html


Maybe, it is not the right choice to use characterAtIndex here?

Can we raise this ticket to prio 9? It seems very important to me to being
able to use accented characters in TkAqua.


Date: 2010-06-25 03:58:47 PDT
Sender: treincke

I tracked this down to be more general. This error occurs everytime you try
to insert an accented character into an entry or text widget (or editable
combobox or whatever text input widget), i.e. everywhere a key event is
triggered. If you enter one of the following keys used for composed
characters ´`^~¨ (keycodes 24, 24+Shift, 10, 45+alt, 32+alt), Tk crashes.

The problem is in tkProcessKeyEvent (file tkMacOSXKeyEvent.c, line 151).
The method

[characters characterAtIndex:0] fails, because there are no characters in
this event, only the keycode. There are also no modifiers at this moment
([theEvent modifierFlags] in line 54).

The problem seems to be that this special case is just not
handled/implemented. Unfortunately, my knowledge of events and all the
functions in the Tk core involved here, is limited, so I can not really fix
it. I tried several things but the only success was to avoid the crash
without anything being inserted into the entry.

So, what is missing here, seems to me:

1. Enter one of the above keys (there may be some others) -> insert the
corresponding character into the entry/text/whatever and select it with
yellow color to mark it as special (see also section 'Setting Focus and
Selection Programmatically' on
http://developer.apple.com/mac/library/documentation/TextFonts/Conceptual/CocoaTextArchitecture/TextEditing/TextEditing.html)

2. Enter a character that can be composed of the first one and the current
one -> delete the selection and insert the composed character instead. If
no such composed character exists just leave the first character alone and
add the current one (maybe some special treatment for 'space').




Date: 2010-02-09 15:20:53 PST
Sender: das

also see 2948152


Attached File ( 1 )

Filename Description Download
tkMacOSXKeyEvent.c patched version of tkMacOSXKeyEvent.c as temporary workaround for the bug Download

Changes ( 8 )

Field Old Value Date By
close_date - 2011-01-24 07:25:13 PST wordtech
status_id Open 2011-01-24 07:25:13 PST wordtech
resolution_id None 2011-01-24 07:25:13 PST wordtech
allow_comments 1 2011-01-24 07:25:13 PST wordtech
File Added 399568: tkMacOSXKeyEvent.c 2011-01-23 03:39:27 PST treincke
priority 8 2010-07-04 16:18:43 PDT dkf
priority 5 2010-02-09 15:21:11 PST das
assigned_to hobbs 2009-12-02 02:26:03 PST treincke