Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-03-18
23:34 • Add attachment 1115904-84.patch to ticket [1115904fff] artifact: a7b3bd2324 user: dgp
23:34 • Ticket [1115904fff] Tcl_EvalEx can evade recursion limit status still Closed... artifact: cfdb2f04c3 user: dgp
23:34 • Closed ticket [1115904fff]. artifact: dc0f811322 user: dgp
22:51 • Ticket [1115904fff]: 5 changes artifact: 2b73b87e5f user: dgp
22:29 • Ticket [1115904fff]: 4 changes artifact: add706e322 user: msofer
2005-02-04
23:56 • Ticket [1115904fff]: 4 changes artifact: ec734007e7 user: dgp
23:56 • Ticket [1115904fff]: 4 changes artifact: 6838ca0e6e user: dgp
23:56 • Add attachment 1115904.patch to ticket [1115904fff] artifact: 730f5bc16b user: dgp
23:56 • Ticket [1115904fff] Tcl_EvalEx can evade recursion limit status still Open w... artifact: 52b2ab747f user: dgp
22:01 • Ticket [1115904fff]: 4 changes artifact: 5f02f84d37 user: dgp
21:47 • Ticket [1115904fff]: 4 changes artifact: ce02caa11f user: dgp
09:39 • Ticket [1115904fff]: 4 changes artifact: 4251e18450 user: dgp
02:23 • New ticket [1115904fff]. artifact: d23fcb346b user: dgp

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: