Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2017-05-03
10:42 • Closed ticket [1939509fff]: Tcl hangs in "exec" (on multi-processor ma... artifact: ffaa438263 user: sebres
2017-04-05
07:34 • Ticket [8bd13f07bd] Closing tcl pipes prevents windows threads from starting up<... artifact: c2bfb6ab5e user: danckaert
2010-06-13
00:34 • Ticket [1939509fff] Tcl hangs in "exec" (on multi-processor machines)<... artifact: 1bacb6f85a user: ferrieux
2009-09-24
13:36 • Ticket [1939509fff]: 4 changes artifact: 94d79324e8 user: ferrieux
06:31 • Ticket [1939509fff]: 4 changes artifact: 319c2a2643 user: pherricoxide
2009-05-01
00:01 • Ticket [1939509fff]: 5 changes artifact: 539cfa00d8 user: ferrieux
2009-03-26
21:29 • Ticket [1939509fff]: 4 changes artifact: c302e6014c user: ferrieux
2008-08-21
06:02 • Ticket [1939509fff]: 4 changes artifact: 6cebb93585 user: ferrieux
06:00 • Ticket [1939509fff]: 4 changes artifact: 1b3716562b user: ferrieux
2008-05-23
16:52 • Ticket [1939509fff]: 4 changes artifact: 615f37aba5 user: fridolin
2008-05-21
18:26 • Ticket [1939509fff]: 4 changes artifact: c67c7c2ccb user: nobody
2008-04-14
15:26 • Ticket [1939509fff]: 4 changes artifact: 48c89f0126 user: nobody
2008-04-12
00:40 • Ticket [1939509fff]: 4 changes artifact: 6902521e69 user: andreas_kupries
2008-04-11
21:13 • Ticket [1939509fff]: 4 changes artifact: e05f82a60e user: dkf
17:34 • Ticket [1939509fff]: 4 changes artifact: 576950d41c user: ferrieux
16:11 • Ticket [1939509fff]: 4 changes artifact: 6d7ae087dc user: dkf
2008-04-10
15:34 • New ticket [1939509fff]. artifact: 3361d40245 user: nobody

Tcl hangs in "exec" (on multi-processor machines)

Closed / Fixed1939509fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 10 years ago
Descriptionplain2008-04-10 15:34:55
Sender: Wolfgang Schmid
        Siemens AG
        Munich, Germany
E-Mail: [email protected]
Phone:  +49 89 636 41098


"Tclsh83" and "tclsh85" hang in exec command, if running on multiprocessor platforms. (The test program is running on a Windows-2003-Server with 2 Dual-Core-Xeons without HyperThreading.)


That's our test environment:

("load,bat" runs "tclsh85" with the script "testexec.tcl" in an endless; "testexec.tcl" starts 5 times a program (Dos-Batch-Script) using "exec" command; the DOS-Batch-Script simply does "exit 0"))

load.bat: (to be called from DOS prompt):
=========
:loop

D:\Tcl8.5.0\bin\tclsh85.exe clock.tcl>> trace.txt

D:\Tcl8.5.0\bin\tclsh85.exe testexec.tcl

goto loop


testexec.tcl:
=============

set fd [open "traceexec.txt" "w"]

puts $fd "\ncallexec 1 started"
flush $fd

set status [catch { exec ./callexec.bat p1 p2 } outcmd]

puts $fd "status: $status, result: $outcmd"
puts $fd "callexec 1 terminated"
flush $fd


# 5 times the same stuff as above


close $fd
exit 0



callexec.bat:Batch-Script that does nothing:
=============  

@echo off

rem echo "callproc started" >> callproc.txt

exit 0


Two trace file will be created:
- trace.txt 
     contains time stamps when "tclsh85" is started
- traceexec.txt
     contains loggings that "callexec.bat" was running and the appropriate exit codes


After a short time (15 - 20 minutes), "tclsh85" hangs.
("No more trace entries are written to "trace.txt")

Is there a chance of fining the error in Tcl8.3 ?

Feel free to contact me via e-mail if information is missing.

Regards,
Wolfgang
dkf Ticket [1939509fff]: 4 changes [History diff]2008-04-11 16:11:07
ferrieuxplain2008-04-11 17:34:32
Logged In: YES 
user_id=496139
Originator: NO

Thanks for bumping it to prio 9 Donal, that's well deserved ;-)
dkfplain2008-04-11 21:13:12
Logged In: YES 
user_id=79902
Originator: NO

Someone's got to do bug triage, and crashes and hangs merit the highest priority initially.
andreas_kupriesplain2008-04-12 00:40:50
Logged In: YES 
user_id=75003
Originator: NO

Note that I cannot help with this.
I have no multi-core box.
[email protected]plain2008-04-14 15:26:23
Logged In: NO 

Small updates on the problem description (from Wolfgang Schmid):

We tried to run the test scripts on different multi-processor platforms and came to the following results:
- Windows Server 2003 (SP1) 32-Bit with 4 CPUs (Xeon): Test scripts are running fine; no problems with "exec"
- Windows Server 2003 R2, Standard 64 Bit edition with 4 CPUs (Xeon): Test fails

The problem seems to happen, if "tclsh" (32 bit application) is running on a 64 Bit machine.


Furhtermore I provide a small update of the test scripts: (as there were small inconsistencies in the scripts.


load.bat: (to be called from DOS prompt):
=========
:loop

D:\Tcl8.5.0\bin\tclsh85.exe testexec.tcl >> trace.txt

goto loop


testexec.tcl:
=============

puts "started at [clock format [clock seconds]]"
flush stdout

set fd [open "traceexec.txt" "w"]

for {set i 0} {$i < 5} {incr i} {
    puts $fd "\ncallexec $i started"
    flush $fd

    set status [catch { exec ./callexec.bat p1 p2 } outcmd]

    puts $fd "status: $status, result: $outcmd"
    puts $fd "callexec $i terminated"
    flush $fd
}

close $fd
exit 0


callexec.bat: 
=============
no changes
nobodyplain2008-05-21 18:26:49
Logged In: NO 

I have a similar problem, just under window XP (32 bit, dual core). Unix is fine.
There are three scripts involved: A.tcl B.tcl D.tcl.
D.tcl is a daemon and runs forever.
A.tcl start B.tcl and waits on its return. B.tcl executes D.tcl in background
(exec tclsh d.tcl). Then B.tcl calls exit, but A.tcl hangs in its exec call. 
If D.tcl is not excuted, A.tcl doesn't hang. It is always reproducable. A.tcl seems 
to hang on these lines from tclWinPipe.c:2899

if (ReadFile(handle, NULL, 0, &count, NULL) == FALSE ||
PeekNamedPipe(handle, NULL, 0, NULL, &count, NULL) == FALSE) {

(There are three threads: PipeReaderThread, CallibrationThread, and TclTkProvide_Ex).
fridolinplain2008-05-23 16:52:30
Logged In: YES 
user_id=13583
Originator: NO

Update for the last comment: maybe this problem is not related to the orignal one, 
because now I can reproduce it on a single core machine and under linux.

a.tcl:
exec wish b.tcl
# exec never returns, but b.tcl calls "exit"
tk_messageBox -message return

b.tcl:
exec wish d.tcl &
tk_messageBox -message exit
# message exit appears
if { [catch exit err] } {
    # you could also replace this block with a plain "exit"
    tk_messageBox -message err=$err
}

d.tcl:
tk_messageBox -message d.tcl
vwait forever

when exec hangs, ps shows a zombi process 'wish <defunct>'
Any ideas? 


Regards,
Christoph Bauer
ferrieuxplain2008-08-21 06:00:49
Logged In: YES 
user_id=496139
Originator: NO

Just a reminder, this may be another facet of [Bug 1997007], the investigation of which is stalled for lack of an easy reproducing setup. All this smells like some fast sequence of Win32 calls near CreateProcess hit a race in the Vista kernel. Things like that can survive very long in a popular OS if the dominant usage is a different sequence...

Anybody here knowing about Windows kernel-debugging ?
ferrieuxplain2008-08-21 06:02:03
Logged In: YES 
user_id=496139
Originator: NO

Just a reminder, this may be another facet of [Bug 1997007], the investigation of which is stalled for lack of an easy reproducing setup. All this smells like some fast sequence of Win32 calls near CreateProcess hit a race in the Vista kernel. Things like that can survive very long in a popular OS if the dominant usage is a different sequence...

Anybody here knowing about Windows kernel-debugging ?
ferrieuxplain2009-03-26 21:29:08
In hindsight, it seems hard to reproduce (no other complaints), and possibly restricted to Vista (can you try on W7 beta?). So I'm starting to regret the prio-9 remark. Maybe we could downgrade it to 8 to leave room for real show-stoppers ?

IOW: I can't imagine tracking this without support from a Vista kernel debugger and/or wizard !
ferrieuxplain2009-05-01 00:01:51
Lowering to prio 8 for the reasons given before.
pherricoxideplain2009-09-24 06:31:50
I've experienced this same problem with both a TCL script calling the Cadence command line utility dsreportgen.exe using exec and also with a TCL script calling another tclsh85 process with exec. It is very intermittent though.

Hardware,

Windows Vista Business Service Pack 2
Dual Intel Xeon L5408's
8GB RAM

If anyone could look into this it would really be appreciated.
ferrieuxplain2009-09-24 13:36:29
A good way to make progress would be to increase the probability of the bug, and also to try to correlate with timing aspects:
  - relative frequencies with the child being (a) dsreportgen, (b) tclsh and (c) cmd (bat files) ?
  - lifecycle in each case: is the child short or long-lived ? Do you spawn many of them quickly at the time of hang, or is it just an isolated [exec] ? If many, do you spawn them from the same parent or in parallel ones ?

Other things to consider too:
 - try fiddling with the various compatibility and admin-rights flags of the parent and child executables
 - any possibility of trying Windows7 ?
 - any knowledge of advanced Windows kernel debugging tools (logging on serial port etc) ?
ferrieuxplain2010-06-13 00:34:03
Interestingly, forcing proc affinity to the child solves the deadlock:

http://groups.google.com/group/comp.lang.tcl/tree/browse_frm/thread/0cff7fd479f75ea7/4332bb3a0d7ddefb?rnum=1&_done=%2Fgroup%2Fcomp.lang.tcl%2Fbrowse_frm%2Fthread%2F0cff7fd479f75ea7%2F975e5a2cb6c7b291%3F#doc_ac3dfecffa4a245d
sebresplain2017-05-03 10:42:20
fixed in core-8-5-branch-fix-1997007 (and in fix-1997007 for 8.6/trunk)
Log in (anonymous is fine) to add a comment.