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,
|