Tk Source Code

View Ticket
Login
Ticket UUID: 6e3c4fb23f50fb4171f4fb7144ba4de9224d52c7
Title: Can crash on Tk load in separate thread after Tk loaded in main thread
Type: Bug Version: 8.6.4
Submitter: andy Created on: 2015-03-10 05:13:10
Subsystem: 99. Other Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2015-03-12 18:51:53
Resolution: None Closed By: nobody
    Closed on:
Description:
I can load and reload Tk in separate threads all day without trouble, but once I load it in the main thread, spawning another thread and attempting to load it in that thread carries the risk of crashing with the following error:

X Error of failed request:  BadColor (invalid Colormap parameter)
  Major opcode of failed request:  88 (X_FreeColors)
  Resource id in failed request:  0x0
  Serial number of failed request:  92
  Current serial number in output stream:  93
User Comments: andy (claiming to be Andy Goth) added on 2015-03-12 18:51:53:
I should mention that this is on 32-bit Slackware 14.1 with all security patches current as of today.  The freetype version is 2.5.5-i486-1_slack14.1.

andy (claiming to be Andy Goth) added on 2015-03-12 18:49:56:
Here's the backtrace.  It seems to be a freetype problem.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb592fb40 (LWP 20575)]
0xb785c8d6 in ?? () from /usr/lib/libfreetype.so.6
(gdb) ba
#0  0xb785c8d6 in ?? () from /usr/lib/libfreetype.so.6
#1  0xb785caca in ?? () from /usr/lib/libfreetype.so.6
#2  0xb7813314 in FT_Render_Glyph_Internal () from /usr/lib/libfreetype.so.6
#3  0xb78133bd in FT_Render_Glyph () from /usr/lib/libfreetype.so.6
#4  0xb7a498b6 in XftFontLoadGlyphs () from /usr/lib/libXft.so.2
#5  0xb7a469bf in XftGlyphExtents () from /usr/lib/libXft.so.2
#6  0xb7a46e26 in XftTextExtents32 () from /usr/lib/libXft.so.2
#7  0xb7d033a3 in Tk_MeasureChars (tkfont=0xb501da88, source=0xb4ee6cf1 "000", 
    numBytes=3, maxLength=-1, flags=3, lengthPtr=0xb592e880)
    at /home/agoth/hawk/build/tcl-build/tk8.6.4/unix/../unix/tkUnixRFont.c:696
#8  0xb7c27b29 in Tk_ComputeTextLayout (tkfont=0xb501da88, 
    string=0xb4ee6cf0 "E000", numChars=4, wrapLength=-1, 
    justify=TK_JUSTIFY_LEFT, flags=3, widthPtr=0xb592e998, 
    heightPtr=0xb592e994)
    at /home/agoth/hawk/build/tcl-build/tk8.6.4/unix/../generic/tkFont.c:2042
#9  0xb7c8bb1d in ComputeTextBbox (canvas=0xb4e3ba10, textPtr=0xb4e52350)
    at /home/agoth/hawk/build/tcl-build/tk8.6.4/unix/../generic/tkCanvText.c:641
#10 0xb7c8b8e0 in ConfigureText (interp=0xb5008a60, canvas=0xb4e3ba10, 
    itemPtr=0xb4e52350, objc=8, objv=0xb5011a08, flags=0)
    at /home/agoth/hawk/build/tcl-build/tk8.6.4/unix/../generic/tkCanvText.c:542
#11 0xb7c8b047 in CreateText (interp=0xb5008a60, canvas=0xb4e3ba10, 
    itemPtr=0xb4e52350, objc=10, objv=0xb5011a00)
    at /home/agoth/hawk/build/tcl-build/tk8.6.4/unix/../generic/tkCanvText.c:296
#12 0xb7c6df71 in ItemCreate (canvasPtr=0xb4e3ba10, itemPtr=0xb4e52350, 
    objc=13, objv=0xb50119f4)
    at /home/agoth/hawk/build/tcl-build/tk8.6.4/unix/../generic/tkCanvas.c:466
#13 0xb7c6fe2e in CanvasWidgetCmd (clientData=0xb4e3ba10, interp=0xb5008a60, 
    objc=13, objv=0xb50119f4)
    at /home/agoth/hawk/build/tcl-build/tk8.6.4/unix/../generic/tkCanvas.c:1310
#14 0xb7d902f3 in Dispatch (data=0xb4e245f4, interp=0xb5008a60, result=0)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclBasic.c:4359
#15 0xb7d90372 in TclNRRunCallbacks (interp=0xb5008a60, result=0, 
    rootPtr=0xb50351f8)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclBasic.c:4392
#16 0xb7d8fc57 in Tcl_EvalObjv (interp=0xb5008a60, objc=10, objv=0xb5011600, 
    flags=2097168)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclBasic.c:4123
#17 0xb7d91dd8 in TclEvalEx (interp=0xb5008a60, 
    script=0x848b7f8 "::map::slave::render 1 {1 0 2 0} {1 0.39999488 2 0} {1 0 2 0} {1 3.5 2 0} {1 0 2 0} {1 -0 2 0} {1 0 2 0} {1 0 2 0}", numBytes=114, 
    flags=131072, line=1, clNextOuter=0x0, 
    outerScript=0x848b7f8 "::map::slave::render 1 {1 0 2 0} {1 0.39999488 2 0} {1 0 2 0} {1 3.5 2 0} {1 0 2 0} {1 -0 2 0} {1 0 2 0} {1 0 2 0}")
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclBasic.c:5261
---Type <return> to continue, or q <return> to quit---
#18 0xb7d91414 in Tcl_EvalEx (interp=0xb5008a60, 
    script=0x848b7f8 "::map::slave::render 1 {1 0 2 0} {1 0.39999488 2 0} {1 0 2 0} {1 3.5 2 0} {1 0 2 0} {1 -0 2 0} {1 0 2 0} {1 0 2 0}", numBytes=-1, 
    flags=131072)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclBasic.c:4926
#19 0xb673fa57 in ThreadSendEval (interp=0xb5008a60, clientData=0x82df800)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/pkgs/thread2.7.2/generic/threadCmd.c:1602
#20 0xb6741e7d in ThreadEventProc (evPtr=0x82df620, mask=-3)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/pkgs/thread2.7.2/generic/threadCmd.c:3114
#21 0xb7e8abc1 in Tcl_ServiceEvent (flags=-3)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclNotify.c:670
#22 0xb7e8ae9c in Tcl_DoOneEvent (flags=-3)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclNotify.c:903
#23 0xb67417b6 in ThreadWait (interp=0xb5008a60)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/pkgs/thread2.7.2/generic/threadCmd.c:2857
#24 0xb673ef0a in ThreadWaitObjCmd (dummy=0x0, interp=0xb5008a60, objc=1, 
    objv=0xb5011340)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/pkgs/thread2.7.2/generic/threadCmd.c:1146
#25 0xb7d902f3 in Dispatch (data=0xb503588c, interp=0xb5008a60, result=0)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclBasic.c:4359
#26 0xb7d90372 in TclNRRunCallbacks (interp=0xb5008a60, result=0, rootPtr=0x0)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclBasic.c:4392
#27 0xb7d8fc57 in Tcl_EvalObjv (interp=0xb5008a60, objc=1, objv=0xb5011340, 
    flags=2097168)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclBasic.c:4123
#28 0xb7d91dd8 in TclEvalEx (interp=0xb5008a60, 
    script=0xb503e328 "thread::wait", numBytes=12, flags=131072, line=1, 
    clNextOuter=0x0, outerScript=0xb503e328 "thread::wait")
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclBasic.c:5261
#29 0xb7d91414 in Tcl_EvalEx (interp=0xb5008a60, 
    script=0xb503e328 "thread::wait", numBytes=12, flags=131072)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclBasic.c:4926
#30 0xb6740046 in NewThread (clientData=0xbffff39c)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/pkgs/thread2.7.2/generic/threadCmd.c:1837
#31 0xb7e37f4e in NewThreadProc (clientData=0x846b7b0)
    at /home/agoth/hawk/build/tcl-build/tcl8.6.4/generic/tclEvent.c:1566
#32 0xb7f8e955 in start_thread () from /lib/libpthread.so.0
#33 0xb7b5185e in clone () from /lib/libc.so.6

andy (claiming to be Andy Goth) added on 2015-03-12 18:43:28:
The behavior changed when upgrading from Tcl 8.6.3 to 8.6.4.  Now it can crash with SIGSEGV when loading Tk into two threads (other than the main thread) at the same time.