infinite for-loop in Tcl 8.6a3
Closed / Fixed2186888fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-10-22 13:56:26
The following small Tcl code loops forever in Tcl8.6a3:
for {set i 20} {$i > 0} {incr i -1} {
puts "i=$i"
continue
}
But only, if source'd !
It runs OK if entered interactively.
I know the example is bogus, but it has been stripped down as much as possible.
My configuration is (RHEL4 machine):
# uname -a
Linux orion 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:32:02 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux
Tcl configured with:
# cd tcl8.6a3/unix
# ./configure --enable-64bit \
--prefix=/usr/local/tcltk8.6a3 \
--enable-symbols
My memory debugger (purify) doesn't complain.
I can create a stack trace if required.
-Jochen
jroemmlerplain2008-10-22 20:56:26
File Added - 298399: loop.tcl
dgpplain2008-10-22 22:49:19
confirmed. Also in 8.6a2.
dgpplain2008-10-22 22:55:36
8.6a1 is ok. Compiled [for] appears to be at fault.
dgpplain2008-10-23 00:47:41
NR-enabling [for] on 2008-07-31 appears to be to blame.
dgpplain2008-10-23 01:08:12
sorry, it's the *non*compiled [for] that is at fault. Given the timing of the appearance, seems to be a flaw in the new TclNRForObjCmd(), probably related to handling TCL_CONTINUE from the body.
dgpplain2008-10-23 01:24:18
I believe this patch is the fix.
Miguel should review and commit.
Original reporter is invited to
test as well.
diff -u -r1.107 tclCmdAH.c
--- generic/tclCmdAH.c 17 Oct 2008 16:32:58 -0000 1.107
+++ generic/tclCmdAH.c 22 Oct 2008 18:22:57 -0000
@@ -1763,7 +1763,7 @@
char *msg = data[3];
- if (result == TCL_OK) {
+ if ((result == TCL_OK) || (result == TCL_CONTINUE)) {
/*
* TIP #280. Make invoking context available to next script.
*
msoferplain2008-10-23 10:30:30
Patch reviewed, accepted, committed. Leaving open as reminder: missing test!
jroemmlerplain2008-10-23 15:26:13
I can also confirm that the suggested patch fixes my problem. Thank you very much for the quick turnaround guys. Good job! Jochen
dgpplain2008-10-23 21:50:12
Alpha testing works! Spread the word!
ferrieuxplain2008-11-17 14:42:31
File Added - 301742: fortest.patch Attaching missing test. File Added: fortest.patch
ferrieuxplain2008-11-17 15:12:55
Committed, closing.
ferrieux Closed ticket [2186888fff].
[History diff]2008-11-17 15:12:56
Log in (anonymous is fine) to add a comment.
Attachments:
- fortest.patch [download] added by ferrieux on 2008-11-17 14:42:31. [details]
- loop.tcl [download] added by jroemmler on 2008-10-22 20:56:26. [details]