Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2003-11-20
05:04 • Closed ticket [845412ffff]: tclCompile.c crash plus 4 other changes artifact: 231565daa6 user: dkf
05:01 • Ticket [845412ffff]: 6 changes artifact: 593fb83a51 user: dgp
04:49 • Ticket [845412ffff]: 4 changes artifact: 3cd0cdbb5c user: dkf
04:47 • Ticket [845412ffff]: 6 changes artifact: b79fc0f1e6 user: dkf
2003-11-19
21:21 • New ticket [845412ffff]. artifact: feb2365345 user: vincentdarley

tclCompile.c crash

Closed / Fixed845412ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2003-11-19 21:21:34
The new {expand} code crashes when attempting to
compile commands with > 255 arguments (or something
like that).

The offending code is this:

if ((delta == 255)
&& (tokenPtr->type != TCL_TOKEN_EXPAND_WORD)) {
    /*
    /*
     * Push an empty list for expansion so our delta
     * between expanded words doesn't overflow a byte
     */
    objIndex = TclRegisterNewLiteral(envPtr, "", 0);
    TclEmitPush(objIndex, envPtr);
    Tcl_DStringAppend(&deltaList, (CONST char
*)&delta, 1);
    delta = 1;

where 'deltaList' is never initialized in this code path.  

A brief look at the code shows (to me at least!) that
there's no way that DString is ever going to be
initialized in the non-TCL_TOKEN_EXPAND_WORD case, so
the code appears to be obviously incorrect.

If necessary I can try to create a test case, but right
now just a big application always crashes at that line.
dkfplain2003-11-20 04:47:19
Logged In: YES 
user_id=79902

I get consistent hard failures with the following code:
    catch {if 1 [string repeat {x } 260]} msg
It should, of course, complain about being unable to locate
the "x" command.
dkfplain2003-11-20 04:49:09
Logged In: YES 
user_id=79902

Fix is to do:
 if (expand && (delta == 255)
since delta's only meaningful when generating code for
command invocations with expanding arguments anyway.
dgpplain2003-11-20 05:01:50
Logged In: YES 
user_id=80530


will commit a fix once I get
a test in place that crashes
before and doesn't after the
fix is applied.
dkf Closed ticket [845412ffff]. [History diff]2003-11-20 05:04:46
Log in (anonymous is fine) to add a comment.