Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Tcl_EvalEx can evade recursion limit

Closed / Fixed1115904fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2005-02-04 02:23:59
Call Tcl_EvalEx() on a command
with significant nesting of substitution...

Tcl_Eval(interp, "foo [foo [foo [...]]]");

Tcl_EvalEx will call TclSubstTokens
to do the command substitution for
the argument.  Which will turn around
and recursively call Tcl_EvalEx to
evaluate the command, etc.

...All without incrementing iPtr->numLevels...

This means an arbitrary deep number
of recursive calls to Tcl_EvalEx can
happen without detection, evading the
limitations meant to be imposed by
[interp recursionlimit].  Eventually this
can lead to stack overflow problems.
dgpplain2005-02-04 09:39:59
File Added - 118493: 1115904.patch

Logged In: YES 
user_id=80530

Attached patch corrects the bug,
but also changes $::errorInfo in
some situations, causing test
basic-46.4 to fail.  Comment?
dgpplain2005-02-04 21:47:33
Logged In: YES 
user_id=80530

that patch doesn't fix the issue
after all.

There's no call to TclInterpReady()
in that code path either, so no
chance to detect the recursion
limit.  Thoughts?
dgpplain2005-02-04 22:01:04
Logged In: YES 
user_id=80530

appears that this issue dates
all the way back to the arrival
of Tcl_EvalEx around Tcl 8.1.
dgpplain2005-02-04 23:56:41
Logged In: YES 
user_id=80530


Here's a better patch with tests.
Please review and apply if acceptable.
dgpplain2005-02-04 23:56:42
File Added - 118584: 1115904.patch
dgpplain2005-02-04 23:56:43
File Deleted - 118493:
msoferplain2005-03-18 22:29:38
Logged In: YES 
user_id=148712

Nice patch - commit please
dgpplain2005-03-18 22:51:49
Logged In: YES 
user_id=80530

fixed in HEAD (8.5a3)
dgpplain2005-03-18 23:34:46
Logged In: YES 
user_id=80530


here's the corresponding patch
for 8.4.  Note that more patching
is required because in Tcl 8.4,
script evaluation substitution
and [subst] substitution haven't
been unified as they have in Tcl 8.5.

Committing for 8.4.10
dgpplain2005-03-18 23:34:47
File Added - 126252: 1115904-84.patch
Log in (anonymous is fine) to add a comment.

Attachments: