Tk Source Code

View Ticket
Login
Ticket UUID: c64420e94ac3e6560ead2065533d254beee538a6
Title: SIGSEGV in tkTextDisp.c und heavy thread::send -async and puts
Type: Bug Version: TCL 8.6.6
Submitter: tombert Created on: 2017-05-30 19:21:38
Subsystem: 99. Other Assigned To: nobody
Priority: 5 Medium Severity: Critical
Status: Open Last Modified: 2017-05-31 19:27:09
Resolution: None Closed By: nobody
    Closed on:
Description:
The following is a duplicate from https://core.tcl.tk/thread/tktview/44499074cb431338a001c9d381913ffca29961d3 now confirmed to be a TK bug:

Luckily I am now able to reproduce with the fairly simple code below. Have [doMeas] running and it will either SIGSEGV or run into this endless loop. One important thing to note! A few lines are printed more than once! For example:

puts from tid0x7fffdbfff700:3543
puts from tid0x7fffdbffd700:3536
...
puts from tid0x7fffdbfff700:3543
puts from tid0x7fffdbfff700:3543

As the [incr ::foo] is evaluated in the main caller this seem to be a message queuing issue?
Note that the bug is not existing if tclsh without tkcon is used.

*** code ***

package re Thread

## show tkcon
set tkconPath [file join [file dirname [file dirname [info nameofexecutable]]] bin tkcon]
uplevel #0 source -encoding utf-8 $tkconPath
uplevel #0 tkcon show

for {set i 0} {$i < 16} {incr i} {
    lappend ::tids [thread::create {thread::wait}]
}

proc startMeas {} {
    foreach tid $::tids {
        thread::send -async $tid [list thread::send -async [thread::id] [list puts "puts from $tid:[incr ::foo]"]]
    }
}

proc doMeas {} {
    startMeas
    after 1 doMeas
}

doMeas

*** code ***

Here is the SIGSEGV

Program received signal SIGSEGV, Segmentation fault.
DisplayText (clientData=0x7b95c0)
    at /home/tombert/cm/tcltk86/dcompile/tk/unix/../generic/tkTextDisp.c:4285
4285		    if ((!(dlPtr2->flags & OLD_Y_INVALID))
(gdb) bt
#0  DisplayText (clientData=0x7b95c0)
    at /home/tombert/cm/tcltk86/dcompile/tk/unix/../generic/tkTextDisp.c:4285
#1  0x00007ffff778b627 in TclServiceIdle ()
    at /home/tombert/cm/tcltk86/dcompile/tcl/generic/tclTimer.c:751
#2  0x00007ffff7761145 in Tcl_DoOneEvent (flags=34)
    at /home/tombert/cm/tcltk86/dcompile/tcl/generic/tclNotify.c:980
#3  0x00007ffff7a66fa6 in Tk_UpdateObjCmd (clientData=0x669980, interp=0x61ccb0, objc=2, 
    objv=0x621288) at /home/tombert/cm/tcltk86/dcompile/tk/unix/../generic/tkCmds.c:1214
#4  0x00007ffff76306a6 in Dispatch (data=0x86ccd8, interp=0x61ccb0, result=0)
    at /home/tombert/cm/tcltk86/dcompile/tcl/generic/tclBasic.c:4358
#5  0x00007ffff7630734 in TclNRRunCallbacks (interp=0x61ccb0, result=0, rootPtr=0x0)
    at /home/tombert/cm/tcltk86/dcompile/tcl/generic/tclBasic.c:4391
#6  0x00007ffff762fec6 in Tcl_EvalObjv (interp=0x61ccb0, objc=2, objv=0x620fa0, 
    flags=2097168) at /home/tombert/cm/tcltk86/dcompile/tcl/generic/tclBasic.c:4121
#7  0x00007ffff763271e in TclEvalEx (interp=0x61ccb0, 
    script=0x7fffb006b400 "puts {puts from tid0x7ffff0ce2700:3574}", numBytes=39, 
    flags=131072, line=1, clNextOuter=0x0,
User Comments: tombert added on 2017-05-30 19:23:25:
Note that I am running in Ubuntu 14 using self-compiled version of TCL with latest sources.