|
2008-03-08
| ||
| 04:08 | • Closed ticket [1899164fff]: Cached bytecode not typed; expr vs. script plus ... artifact: d5ea1d04d3 user: dgp | |
| 02:26 | • Ticket [1899164fff]: 4 changes artifact: a960cd793a user: dgp | |
|
2008-03-05
| ||
| 01:52 | • Ticket [1899164fff]: 1 change artifact: 8a119deadc user: dgp | |
| 01:52 | • Ticket [1899164fff]: 5 changes artifact: 58a27ea52b user: dgp | |
|
2008-02-23
| ||
| 00:36 | • Ticket [1899164fff]: 6 changes artifact: ad5faa14f5 user: dgp | |
| 00:15 | • Ticket [1899164fff]: 5 changes artifact: cc1af8f618 user: dgp | |
|
2008-02-22
| ||
| 22:16 | • Ticket [1899164fff]: 4 changes artifact: 8fa5ddfcf0 user: dgp | |
| 22:11 | • Ticket [1899164fff]: 5 changes artifact: e498e2eaa9 user: dgp | |
| 22:11 | • Ticket [1899164fff]: 4 changes artifact: f1770a5744 user: dgp | |
| 04:55 | • Ticket [1899164fff]: 4 changes artifact: 5814854798 user: dgp | |
|
2008-02-21
| ||
| 21:55 | • New ticket [1899164fff]. artifact: d6ec06cb6b user: dgp | |
Cached bytecode not typed; expr vs. script
Closed / Fixed1899164fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2008-02-21 21:55:45
The implementation of Tcl_ExprObj()
tries to detect when the Tcl_Obj
passed in is a PRECOMPILED "bytecode"
value, and then validate interps and
forgive any epoch expiration before
executing the bytecode.
This is incorrect, because a PRECOMPILED
value has been compiled as a script to
produce the bytecode, and that bytecode
is not a valid set of instructions to
interpret the same string as an expression.
([eval {0}] and [expr {0}] are different!)
Worse still, the cleanup stages at the
end of Tcl_ExprObj() will free the bytecode,
and since PRECOMPILED values suppress the
original string rep., the original bytecode
will be lost with no way to recover it.
Attached is a patch to make Tcl_ExprObj()
do the only sensible thing -- raise an
error.
No one has noticed this, probably because
it appears difficult and unnatural to
pass a PRECOMPILED value to Tcl_ExprObj(),
possibly even requiring internals intrusion
to accomplish it.
If there's a way to create a test case for
this with reasonable effort in either the
Tcl or the tbcload test suite, I'd appreciate
that contribution. Otherwise, just review
and commit this fix please.
dgpplain2008-02-22 04:55:46
File Added - 267449: precompexpr.patch
dgpplain2008-02-22 22:11:18
Logged In: YES
user_id=80530
Originator: YES
The problem is more widespread
than I thought:
% proc 0+0 {} {return WTF?}
% set script { 0+0 }
0+0
% time $script
34 microseconds per iteration
% expr $script
WTF?
dgpplain2008-02-22 22:11:19
File Deleted - 267449:
dgpplain2008-02-22 22:16:55
Logged In: YES
user_id=80530
Originator: YES
% proc 0+0 {} {return WTF?}
% set script 0+0
0+0
% time $script
40 microseconds per iteration
% expr $script
WTF?
% append script { }
0+0
% expr $script
0
% time $script
5 microseconds per iteration
% expr $script
0
% if 1 $script
0
dgpplain2008-02-23 00:15:18
Logged In: YES user_id=80530 Originator: YES I misread the codePtr->refCount management, so I was wrong about the danger of losing the precompiled bytecode. Because cached bytecode is not so transient, the dangers of using the wrong bytecodes do flow both ways.
dgpplain2008-02-23 00:36:37
Logged In: YES user_id=80530 Originator: YES this isn't about tbcload anymore, so assigning to msofer for assistance when he returns.
dgpplain2008-03-05 01:52:13
Logged In: YES user_id=80530 Originator: YES tests committed
dgp Ticket [1899164fff]: 1 change
[History diff]2008-03-05 01:52:32
dgpplain2008-03-08 02:26:48
Logged In: YES user_id=80530 Originator: YES Fixed on HEAD for 8.5.2.
dgpplain2008-03-08 04:08:54
Logged In: YES user_id=80530 Originator: YES and fixed for 8.4.19 too.
Log in (anonymous is fine) to add a comment.