Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-08-07
08:03 • Ticket [442665ffff] gets corrupts freed object status still Closed with 6 ... artifact: 3a7b5a079b user: jikamens
08:01 • Ticket [442665ffff]: 6 changes artifact: 4bbabd2e25 user: dgp
07:37 • Ticket [442665ffff]: 6 changes artifact: 599bb608ff user: jikamens
05:19 • Closed ticket [442665ffff]. artifact: 6cd1a96d0f user: andreas_kupries
2001-08-06
22:24
2001-08-06 Andreas Kupries <[email protected]> * generic/tclIOCmd.c (Tcl_Gets... check-in: c3d640b755 user: andreas_kupries tags: core-8-3-1-branch
22:17
2001-08-06 Andreas Kupries <[email protected]> * generic/tclIOCmd.c (Tcl_Gets... check-in: 29ddd6bb07 user: andreas_kupries tags: trunk
2001-07-20
03:16 • Ticket [442665ffff] gets corrupts freed object status still Open with 4 ot... artifact: 8c84eaad97 user: jikamens
03:09 • Ticket [442665ffff]: 4 changes artifact: 87d4f42573 user: andreas_kupries
02:10 • Ticket [442665ffff]: 4 changes artifact: 8186848488 user: jikamens
01:18 • Ticket [442665ffff]: 1 change artifact: 48b749cff7 user: andreas_kupries
00:38 • Ticket [442665ffff]: 4 changes artifact: a61f9936aa user: andreas_kupries
00:31 • Ticket [442665ffff]: 4 changes artifact: 2254826416 user: andreas_kupries
2001-07-19
23:54 • Ticket [442665ffff]: 2 changes artifact: 426b55c6e7 user: dgp
13:19 • Add attachment diff to ticket [442665ffff] artifact: af9ca6e175 user: jikamens
13:19 • Ticket [442665ffff] gets corrupts freed object status still Open with 4 othe... artifact: 4ed4dccdfe user: jikamens
06:19 • New ticket [442665ffff]. artifact: 02b5172395 user: jikamens

[gets] corrupts freed object

Closed / Fixed442665ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-07-19 06:19:49
The function Tcl_GetsObjCmd in tclIOCmd.c can corrupt a
freed object if it is called with objc == 3.  This is
because it retrieves resultPtr and does not increment
its reference count, but then calls Tcl_ObjSetVar2,
which causes the retrieved resultPtr object to be
released.  I will attach a patch, which I hope is
correct (if not, please E-mail me and let me know why,
so I can understand all of this better; I barely
understand it).
jikamensplain2001-07-19 13:19:50
File Added - 8593: diff
dgp Ticket [442665ffff]: 2 changes [History diff]2001-07-19 23:54:17
andreas_kupriesplain2001-07-20 00:31:05
Logged In: YES 
user_id=75003

Regarding "Tcl_ObjSetVar2" releasing the interp result. I 
took a look at the principal code, in "Tcl_SetVar2Ex" and 
found that the interp result is only released in the case 
of an error. In that case the result of the function is 
NULL, and this condition is catched by "Tcl_GetsObjCmd". So 
this shouldn't be a problem.
andreas_kupriesplain2001-07-20 00:38:23
Logged In: YES 
user_id=75003

Still, in the code as is the call to "Tcl_GetsObj" can and 
will directly modify the interp result without announcing 
its reference in the case of objc == 2. This gave trouble 
in the past with transformations, i.e. channel drivers, 
which called back into the script level, thus modifying the 
interp result, if they didn't do a save/restore on the 
previous result.
andreas_kupries Ticket [442665ffff]: 1 change [History diff]2001-07-20 01:18:59
jikamensplain2001-07-20 02:10:52
Logged In: YES 
user_id=274776

Hmm.  I'm not following everything that Andreas is saying. 
I confess that I didn't fully understand the mechanisms I
was trying to fix.  But I assure you that TCL was
core-dumping without my fix, and when I recompiled it with
TCL_MEM_DEBUG, the call to Tcl_SetIntObj was failing,
claiming that it was trying to set a disposed pointer.  When
I recompiled with my fix, that error went away when
TCL_MEM_DEBUG remained set and the coredump went away when I
unset it.

I don't think I have anything more useful to contribute :-).
andreas_kupriesplain2001-07-20 03:09:19
Logged In: YES 
user_id=75003

Can you attach the script which produces the core dump to 
this item ?
jikamensplain2001-07-20 03:16:21
Logged In: YES 
user_id=274776

No, I can't, because it's a large package (cbb, the Check
Book Balancer) with lots of local customizations, and the
coredump seems to be dependent on the specific data being
imported, and I can't exactly send you my checkbook data.

I had sort of hoped that the correctness of my fix would be
apparent to someone who understands tcl's internals more
than I do.  It was *mostly* apparent to me, and I barely
understand the internals at all.  Apparently it's more
complex than I thought.
andreas_kupriesplain2001-08-07 05:19:00
Logged In: YES 
user_id=75003

Comitted.
jikamensplain2001-08-07 07:37:10
Logged In: YES 
user_id=274776

I'm finding this whole conversation really puzzling.  I'm
sorry to keep repeating myself, but I find it necessary to
do so....

As I said, I can't comment on *why* there's a problem in the
code.  All I know is that when I compiled TCL with memory
debugging enabled, the memory debugging code told me quite
explicitly that there was a problem, and after I applied the
fix which I submitted, the problem went away.

What I find puzzling is that you seem willing to write off
this bug and close it without determining why I was seeing a
problem before my fix and not afterwards.  It seems like you
think I'm making up the bug report or something.  Why would
I make up the fact that the TCL memory debugging code was
reporting a problem before my fix and not reporting a
problem afterwards?

In short, it seems to me that you should not close the bug
without taking any action until you have understood why I
was seeing a problem, and it seems that you haven't done
that.
dgpplain2001-08-07 08:01:08
Logged In: YES 
user_id=80530

Why are you complaining?  Your patch was accepted into
the development sources and will be part of releases
Tcl 8.3.4 and Tcl 8.4a3.  Isn't that what you want?
jikamensplain2001-08-07 08:03:27
Logged In: YES 
user_id=274776

Doh!  I was complaining because I thought my patch *wasn't*
accepted!  I misread the bug report because I read it from
top to bottom when I should have been reading it from bottom
to top.  I find this interface which puts the description of
the bug first but then puts comments from most to least
recent quite confusing :-).

Sorry about that.  Thanks.
Log in (anonymous is fine) to add a comment.

Attachments: