Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-05-25
13:00 • Closed ticket [05489ce335]: for-8.[124568] stack management panic plus 6 oth... artifact: 5e5e1d8298 user: dkf
2015-10-04
11:00 • Ticket [05489ce335]: 5 changes artifact: 9e011a0190 user: dkf
10:58
[05489ce335] Constrain broken tests. check-in: 74d7c078c4 user: dkf tags: core-8-5-branch
2015-09-30
21:17 • Ticket [05489ce335] for-8.[124568] stack management panic status still Open ... artifact: 3eb3c4db74 user: dkf
2015-09-24
19:08 • Ticket [05489ce335]: 3 changes artifact: 5819b69d45 user: dgp
19:02 • Ticket [05489ce335]: 3 changes artifact: eeb0037b25 user: dgp
14:18 • Ticket [05489ce335]: 3 changes artifact: adde5417b1 user: dgp
12:20 • Ticket [05489ce335]: 4 changes artifact: 80421ddbc7 user: dgp
2015-09-23
11:48 • Ticket [05489ce335]: 5 changes artifact: ffa46bfd05 user: dgp
11:42 • New ticket [05489ce335]. artifact: 452eff87f4 user: dgp

for-8.[124568] stack management panic

Closed / Fixed05489ce33509af52219db03214faf1445dcab5a4Created 11 years agoUpdated 3 years ago
Descriptionplain2015-09-23 11:42:17
With a --enable-symbols=all build:

$ make test TESTFLAGS="-file for.test -match for-8.1"
...
for.test
Test file error: 
Bad stack top 5 at pc 92 in TclExecuteByteCode (min 0, max 4)
 executing eval break
TclExecuteByteCode execution failure: bad stack top
Referenced by1
dgpplain2015-09-23 11:48:57
Bisect blames:

checkout:     0710a46828a997a963466ea7e51fb51f88c2521d 2015-08-03 07:17:27 UTC
comment:      Backport the fixes to handling of continue in for-step clauses.
              (user: dkf)

http://core.tcl.tk/tcl/info/0710a46828a997a9
dgpplain2015-09-24 12:20:05
Similar trouble with multiple tests.
dgpplain2015-09-24 14:18:24
This is more than just stack management issues.
The bytecode produces the wrong result.

Here's a more direct demo:

% info patch
8.6.4
% apply {{} {list GOOD [for {} {1} {list BAD [break]} {}]}}
GOOD {}

% info patch
8.5.18
% apply {{} {list GOOD [for {} {1} {list BAD [break]} {}]}}
BAD {}

Trunk Tcl gets it right. core-8-5-branch is broken.

When working properly, the [break] exception should clear the BAD
off the execution stack and then the list {GOOD {}} gets formed
from GOOD lower on the stack and the {} that is the result of [for].

In 8.5, the BAD is not taken off the stack, and the list is formed
out of the wrong values.
dgpplain2015-09-24 19:02:35
Tcl 8.6 used to get this wrong too 

http://core.tcl.tk/tcl/tktview?name=2835313

It got fixed, but the ticket declares backport
to be impossible.

Two options it seems to me:

1) Determine how to make a backport of the fix
not impossible and do it.

2) Resolve that this will stay broken, accept
that and then backout the checkin

http://core.tcl.tk/tcl/info/0710a46828a997a9

that started up the visible failure mode noted here.
dgpplain2015-09-24 19:08:22
Created a branch that takes door number 2.

This is really a phony solution in that it
doesn't make anything any better; it just
removes the tests that expose the brokenness.
A better answer in this direction might be
some test constraint to avoid panics when
all debugging is on.

Real answer is either backport of the fix, which
I'm willing to accept really is impossible, or
the shoving of Tcl 8.5.* off the stage.

At this point, I'll leave things to dkf.
dkfhtml2015-09-30 21:17:44

The backport of the 8.6 solution would require the exact stack depth calculation fixes (which were a massive PITA in the 8.6 development, but necessary) and backporting a single bytecode so that expansion stack entries could be dropped. Which should act as a massive hint as to the sorts of tests that you should be thinking about! The stack depth fixes are particularly important to the example described in this bug report; popping the BAD is exactly what is necessary, but that requires knowing that that's the stack entry that's surplus...

With those two preparatory changes in place, the fix is just to rewrite break/continue (when in a looping context) to a sequence of expansion-pops, ordinary-pops and a jump, which should be pretty simple actually. But you need the exact stack depth fixes to safely know how much to pop at compile time, and the extra bytecode in order to clean up the expansion stack.

dkfhtml2015-10-04 11:00:14

I've constrained the tests that cause trouble with bug-05489ce335 so that the test suite should not crash.

dkfmarkdown2024-05-25 13:00:13

It's not going boom in anything from 8.6 on, which is the oldest supported version, and would have been onerous to fix before that (given the complexity of the changes to the code issuing to support this).

Closing...

Log in (anonymous is fine) to add a comment.