Skip to content
Tcl Source Code View Ticket
Login

View Ticket

stack imbalance panic from [list]

Closed / Fixed3614102fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 14 years ago
Descriptionplain2013-05-29 15:43:56
% proc foo {} {
list [append ::dgp a b c]
}
% foo
bad stack adjustment when compiling list (was 2 instead of 1)
dgpplain2013-05-29 22:50:09
Still investigating, but I think the trouble is that
TclCompileScript() is failing to clean up the
record of stack usage when a compileProc fails.
dgpplain2013-05-29 22:53:19
8.6.0 release will not show the failure.  The new [list]
compiler is needed to demonstrate.  I think it's exposing,
rather than creating the flaw, though.
dgpplain2013-05-29 23:20:22
Checkin [efa1b5bb6b] is where the debug panic
starts.
dgpplain2013-05-29 23:22:22
Oh, I missed that the "append multiple" compiler
was new in that checkin too.
dgpplain2013-05-29 23:29:15
Here's one that fails in 8.6.0:

% proc foo {} {
list [array exists ::foo(bar)]
}
% foo
bad stack adjustment when compiling list (was 3 instead of 1)
dgpplain2013-05-29 23:32:31
And strangely enough, that one is fixed
on the trunk.
dgpplain2013-05-29 23:50:43
But this one isn't:

% proc foo {} {
list [::tcl::array::exists ::foo(bar)]
}
% foo
bad stack adjustment when compiling list (was 2 instead of 1)
make: *** [shell] Aborted
dgpplain2013-05-30 00:09:32
...because CompileToCompiledCommand()
gets this right where TclCompileScript() fails.

Here's a stable test case I will commit:
test compile-19.0 {Bug 3614102: reset stack housekeeping} -body {
    # This will panic in a --enable-symbols=compile build, unless bug is fixed.
    apply {{} {list [if 1]}}
} -returnCodes error -match glob -result *
dgpplain2013-05-30 00:20:55
allow_comments - 1

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