Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-03-11
05:10 • Ticket [1153871fff] Tcl_CreateObjTrace destroyes user-supplied clientData st... artifact: b3fa730a7c user: dgp
05:10 • Closed ticket [1153871fff]. artifact: 4893896859 user: dgp
2005-03-09
06:46 • Ticket [1153871fff]: 4 changes artifact: ea6331a908 user: dgp
06:46 • Add attachment 1153871-8.5.patch to ticket [1153871fffffffff|1153871fff... artifact: dd3e0ee763 user: dgp
06:45 • Add attachment 1153871.patch to ticket [1153871fff] artifact: 27f6ed6d69 user: dgp
06:45 • Ticket [1153871fff] Tcl_CreateObjTrace destroyes user-supplied clientData st... artifact: 0ae85eaf04 user: dgp
06:45 • Ticket [1153871fff]: 4 changes artifact: c2052824b8 user: dgp
2005-03-02
06:19 • Ticket [1153871fff]: 1 change artifact: 00fa5c7731 user: dgp
06:19 • Ticket [1153871fff]: 1 change artifact: 770a54b19b user: dgp
04:14 • Ticket [1153871fff]: 4 changes artifact: d050f7348e user: msofer
04:00 • Ticket [1153871fff]: 4 changes artifact: fae357036f user: yurivict
02:10 • Ticket [1153871fff]: 4 changes artifact: 8e82cd6e47 user: msofer
2005-03-01
08:34 • Ticket [1153871fff]: 4 changes artifact: d49d168093 user: yurivict
08:01 • Ticket [1153871fff]: 5 changes artifact: 0802e38176 user: msofer
2005-02-28
23:20 • New ticket [1153871fff]. artifact: d98b4fdc91 user: yurivict

Tcl_CreateObjTrace destroyes user-supplied clientData

Closed / Fixed1153871fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2005-02-28 23:20:31
Caller supplied clientData argument to Tcl_CreateObjTrace.

OBSERVE\D PROBLEM:
  coredump, analysis shows that clientData pointer
supplied by user was typecasted to the pointer to the
private structure TraceCommandInfo defined only in
tclCmdMZ.c:

tclCmdMZ.c:4318:
  tcmdPtr = (TraceCommandInfo*)tracePtr->clientData;
  tcmdPtr->curFlags = traceFlags;
  tcmdPtr->curCode  = code;

and subsequent assignments to TraceCommandInfo destroy
user-owned memory area.

Yuri
msoferplain2005-03-01 08:01:20
Logged In: YES 
user_id=148712

Core dump => setting to max priority 

I assume that this was not triggered by a tcl script, right?
In any case, we also seem to be lacking a test in the testsuite.
yurivictplain2005-03-01 08:34:52
Logged In: YES 
user_id=129507

Tcl_CreateObjTrace was called before any TCLs,
then memory corrution way down the road by subsequent TCL
scripts.

It's very obscure, I could only catch it by "gdb watch" command.

Documentation should be fixed too since it says something
about "arbitrary one-word value" which is not even the case.

Yuri
msoferplain2005-03-02 02:10:31
Logged In: YES 
user_id=148712

Looking at the code: Tcl_CreateObjTrace should only be
passed flag values 0 or TCL_ALLOW_INLINE_COMPILATION. So we
definitely have a bug in that we're not checking that value.

What you are observing suggests that the flag somehow got a
different value - or that that flag value itself was
corrupted. Could you please confirm what flag value was
passed to Tcl_CreateObjTrace?
yurivictplain2005-03-02 04:00:21
Logged In: YES 
user_id=129507

Actually it was called twice, for enter and leave.
for enter with flags TCL_ALLOW_INLINE_COMPILATION
for leave with flags TCL_TRACE_LEAVE_EXEC |
TCL_ALLOW_INLINE_COMPILATION
----
seems to be unconditionally wrong for TCL to dereference
user-supplied clientData, line:
tcmdPtr = (TraceCommandInfo*)tracePtr->clientData;

Yuri
msoferplain2005-03-02 04:14:17
Logged In: YES 
user_id=148712

(1) Agreed about "unconditionally wrong", not denying the bug!

(2) Tcl_CreateObjTrace is documented to accept only
TCL_ALLOW_INLINE_COMPILATION as flag value. It should
probably throw an error (return NULL) if it receives any
other value. Note that under these conditions, the
clientData is not deref'ed or overwritten.

(3) Alternatively, we may find a way to enable
Tcl_CreateObjTrace to process correctly other flag values.
This implies some internal redesign.

In the meantime - please use the function as documented.
dgp Ticket [1153871fff]: 1 change [History diff]2005-03-02 06:19:00
dgp Ticket [1153871fff]: 1 change [History diff]2005-03-02 06:19:01
dgpplain2005-03-09 06:45:24
Logged In: YES 
user_id=80530

please test whether this patch
for Tcl 8.4.9 corrects the problem.
dgpplain2005-03-09 06:45:26
File Added - 124730: 1153871.patch
dgpplain2005-03-09 06:46:51
File Added - 124731: 1153871-8.5.patch

Logged In: YES 
user_id=80530


Here's the corresponding patch
for Tcl 8.5a3 ...
dgp Closed ticket [1153871fff]. [History diff]2005-03-11 05:10:48
dgpplain2005-03-11 05:10:49
Logged In: YES 
user_id=80530

fixes committed for 8.4.10 and 8.5a3.
Log in (anonymous is fine) to add a comment.

Attachments: