| Ticket UUID: | 1884782 | |||
| Title: | simple Tk app to display data crashes wish | |||
| Type: | Bug | Version: | obsolete: 8.4.7 | |
| Submitter: | nobody | Created on: | 2008-02-01 19:28:54 | |
| Subsystem: | 46. Unix Fonts | Assigned To: | hobbs | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Closed | Last Modified: | 2026-10-22 17:22:35 | |
| Resolution: | Fixed | Closed By: | serhiy.storchaka | |
| Closed on: | 2026-09-25 07:37:38 | |||
| Description: |
A developer contacted me asking me for help. He had data in a Chinese encoding that he needed to display in a Tcl/Tk application. After asking on the wiki and comp.lang.tcl, it appears that Tcl doesn't support this encoding. It was recommended that he use iconv to convert the encoding into one that is supported.
He did so, then, with the following application, attempted to display the data. Note that when _I_ run this script, I get the chinese output as expected. When he runs it, he gets a Bus error core dump on SPARC Solaris 9... This is with a standard Tcl interpreter.
Okay, here's the application:
package require Tk
frame .f
text .text -bg white -wrap word
pack .f -side top
pack .text -side left -expand true -fill both
.text configure -font "helvetica-22"
.text delete 1.0 end
set f [open "~/foo.utf8" "r"]
fconfigure $f -encoding "utf-8"
set buf [read $f 32000]
.text insert end $buf
close $f
I will attempt to attach the foo.utf8 to this ticket.
Note that while the original report of this problem is from Tcl/Tk 8.4.7 - the developer reports seeing the same problem with 8.5.0. However, I don't have the stack trace from the tcl/tk 8.5 attempt - just this one.
The stack trace is:
$ dbx -f /usr/tcl84/bin/tclsh core
For information about new features see `help changes'
To remove this message, put `dbxenv suppress_startup_message 7.0' in your .dbxrc
Reading tclsh
core file header read successfully
Reading ld.so.1
Reading libtcl8.4g.so
Reading libdl.so.1
Reading libsocket.so.1
Reading libnsl.so.1
Reading libm.so.1
Reading libc.so.1
Reading libmp.so.2
Reading libc_psr.so.1
Reading libtk8.4g.so
Reading libX11.so.4
Reading libXext.so.0
program terminated by signal BUS (invalid address alignment)
Current function is Tcl_UtfToUniChar
338 | ((str[1] & 0x3F) << 6) | (str[2] & 0x3F));
(dbx 1) where
=>[1] Tcl_UtfToUniChar(str = 0xffbfdaad "\xe5\x80\x80\xff\xbf\xdc\x9c", chPtr = 0xffbfda9d), line 338 in "tclUtf.c"
[2] UtfToUcs2beProc(clientData = (nil), src = 0xffbfdaad "\xe5\x80\x80\xff\xbf\xdc\x9c", srcLen = 3, flags = 7, statePtr = 0xffbfd9c4, dst = 0xffbfda9d "", dstLen = 14, srcReadPtr = 0xffbfd9d0, dstWrotePtr = 0xffbfd9cc, dstCharsPtr = 0xffbfd9c8), line 616 in "tkUnixFont.c"
[3] Tcl_UtfToExternal(interp = (nil), encoding = 0x3e950, src = 0xffbfdaad "\xe5\x80\x80\xff\xbf\xdc\x9c", srcLen = 3, flags = 7, statePtr = 0xffbfd9c4, dst = 0xffbfda9d "", dstLen = 14, srcReadPtr = 0xffbfd9d0, dstWrotePtr = 0xffbfd9cc, dstCharsPtr = 0xffbfd9c8), line 1093 in "tclEncoding.c"
[4] FontMapLoadPage(subFontPtr = 0xffbfdc9c, row = 20), line 2097 in "tkUnixFont.c"
[5] FontMapLookup(subFontPtr = 0xffbfdc9c, ch = 21457), line 1985 in "tkUnixFont.c"
[6] CanUseFallback(fontPtr = 0xc91e8, faceName = 0xc3978 "fixed", ch = 21457, fixSubFontPtrPtr = (nil)), line 2429 in "tkUnixFont.c"
[7] FindSubFontForChar(fontPtr = 0xc91e8, ch = 21457, fixSubFontPtrPtr = (nil)), line 1858 in "tkUnixFont.c"
[8] Tk_MeasureChars(tkfont = 0xc91e8, source = 0xc96a4 "<\xe5\x8f\x91\xe6\x98\x8e\xef\xbc\x88\xe8\xae\xbe\xe8\xae\xa1\xef\xbc\x89\xe4\xba\xba>=\xe5\x89\x8d,\xe6\xbb\x9d,\xe8\xbf\x9b\n", numBytes = 35, maxLength = 560, flags = 0, lengthPtr = 0xffbfe08c), line 1051 in "tkUnixFont.c"
[9] MeasureChars(tkfont = 0xc91e8, source = 0xc96a4 "<\xe5\x8f\x91\xe6\x98\x8e\xef\xbc\x88\xe8\xae\xbe\xe8\xae\xa1\xef\xbc\x89\xe4\xba\xba>=\xe5\x89\x8d,\xe6\xbb\x9d,\xe8\xbf\x9b\n", maxBytes = 36, startX = 0, maxX = 560, tabOrigin = 0, nextXPtr = 0xffbfe124), line 5216 in "tkTextDisp.c"
[10] TkTextCharLayoutProc(textPtr = 0x31500, indexPtr = 0xffbfe20c, segPtr = 0xc9698, byteOffset = 0, maxX = 560, maxBytes = 36, noCharsYet = 1, wrapMode = TEXT_WRAPMODE_WORD, chunkPtr = 0x3a198), line 4485 in "tkTextDisp.c"
[11] LayoutDLine(textPtr = 0x31500, indexPtr = 0xffbfe2d4), line 1007 in "tkTextDisp.c"
[12] UpdateDisplayInfo(textPtr = 0x31500), line 1321 in "tkTextDisp.c"
[13] TkTextPixelIndex(textPtr = 0x31500, x = 0, y = 0, indexPtr = 0xffbfe42c), line 4139 in "tkTextDisp.c"
[14] TkTextPickCurrent(textPtr = 0x31500, eventPtr = 0x316b4), line 1411 in "tkTextTag.c"
[15] DisplayText(clientData = 0x31500), line 2248 in "tkTextDisp.c"
[16] TclServiceIdle(), line 704 in "tclTimer.c"
[17] Tcl_DoOneEvent(flags = -3), line 955 in "tclNotify.c"
[18] Tk_MainLoop(), line 1500 in "tkEvent.c"
[19] Tcl_Main(argc = 1, argv = 0xffbfe8c0, appInitProc = 0x10820 = &Tcl_AppInit(Tcl_Interp *interp)), line 485 in "tclMain.c"
[20] main(argc = 2, argv = 0xffbfe8bc), line 90 in "tclAppInit.c"
(dbx 2)
| |||
| User Comments: |
serhiy.storchaka added on 2026-09-25 07:37:38:
Fixed in 8.4.14 and 8.5 by [eef92b1064] ([da4f3b7133] for 8.4), the fix for Bug 1122671: the misaligned access in lvirden added on 2008-02-04 20:35:23: Logged In: YES user_id=15949 Originator: NO apparently, I don't have the ability to upload anything to this item. I'll see if I can mail it. lvirden added on 2008-02-04 20:32:48: Logged In: YES user_id=15949 Originator: NO My developer tried the simple script using tcl/tk 8.5, and got mixed results. The good news was that it did not core dump. The bad news is that the characters displayed were not Chinese. I'm going to attempt to upload the screen dump he sent me ... cc_benny added on 2008-02-02 22:08:23: Logged In: YES user_id=143885 Originator: NO Comparing the stack trace with the source and according to comments in tk/tkUnixFont.c, this would be a dup of bug #1122671 (which I can't locate right now on SF :-(). This is fixed since 2006 (in 8.4.14 and in 8.5a5). Can you get your contact to give us a stack trace from 8.5.0? This might be a different bug or a regression. lvirden added on 2008-02-02 02:30:28: Logged In: YES user_id=15949 Originator: NO Jeff - sorry that I wasn't logged in when this was submitted. [email protected] added on 2008-02-02 02:28:55: File Added - 264671: foo.utf8 | |||
Attachments:
- foo.utf8 [download] added by [email protected] on 2008-02-02 02:28:55. [details]
