Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-11-17
15:12 • Closed ticket [2186888fff]: infinite for-loop in Tcl 8.6a3 plus 2 other chan... artifact: 1dac896c07 user: ferrieux
15:12 • Ticket [2186888fff]: 4 changes artifact: cd8ae3fab2 user: ferrieux
14:42 • Ticket [2186888fff]: 4 changes artifact: 7b70776a39 user: ferrieux
14:42 • Add attachment fortest.patch to ticket [2186888fff] artifact: d5c8c03941 user: ferrieux
2008-10-23
21:50 • Ticket [2186888fff] infinite for-loop in Tcl 8.6a3 status still Open with 4 ... artifact: b66c17c5fb user: dgp
15:26 • Ticket [2186888fff]: 4 changes artifact: 04f7894d65 user: jroemmler
10:30 • Ticket [2186888fff]: 6 changes artifact: 294c9ed07c user: msofer
01:24 • Ticket [2186888fff]: 4 changes artifact: 070acf55af user: dgp
01:08 • Ticket [2186888fff]: 4 changes artifact: b1f6d7fd3a user: dgp
00:47 • Ticket [2186888fff]: 5 changes artifact: 5aca1373da user: dgp
2008-10-22
22:55 • Ticket [2186888fff]: 7 changes artifact: 7299ae1616 user: dgp
22:49 • Ticket [2186888fff]: 4 changes artifact: 9f1ecf41c0 user: dgp
20:56 • Add attachment loop.tcl to ticket [2186888fff] artifact: e0e100a40c user: jroemmler
20:56 • Ticket [2186888fff] infinite for-loop in Tcl 8.6a3 status still Open with 4 ... artifact: 9974e1a090 user: jroemmler
13:56 • New ticket [2186888fff]. artifact: e89a5d903a user: jroemmler

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: