Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2009-10-18
18:22 • Ticket [988703ffff] tsdPtr->objThreadMap and data never freed in tclObj.c... artifact: 50f4b28d81 user: mistachkin
2009-06-18
16:44 • Closed ticket [988703ffff]. artifact: 9e6cef8144 user: dkf
16:15 • Ticket [988703ffff]: 1 change artifact: c1aaec2de5 user: dkf
16:15 • Ticket [988703ffff]: 5 changes artifact: 5a89e0a410 user: dkf
15:42 • Ticket [988703ffff]: 1 change artifact: e8dff8ce08 user: dkf
2009-03-15
15:37 • Ticket [988703ffff]: 4 changes artifact: ef0ed651b1 user: dkf
12:36 • Ticket [988703ffff]: 1 change artifact: 6bad32175b user: mistachkin
12:12 • Ticket [988703ffff]: 5 changes artifact: 7ae659f233 user: mistachkin
12:12 • Ticket [988703ffff]: 4 changes artifact: 465894d377 user: mistachkin
12:12 • Add attachment TclDbInitNewObj.zip to ticket [988703ffffffffff|988703ff... artifact: 0463af27d1 user: mistachkin
2007-06-19
13:33 • Ticket [988703ffff] tsdPtr->objThreadMap and data never freed in tclObj.c... artifact: ad198d5f7f user: mistachkin
12:58 • Ticket [988703ffff]: 4 changes artifact: 898e0dfd0a user: mistachkin
2005-05-31
19:51 • Ticket [988703ffff]: 4 changes artifact: 5a983e4620 user: vasiljevic
09:17 • Ticket [988703ffff]: 1 change artifact: 052cef0aa0 user: hobbs
2004-11-18
01:11 • Ticket [988703ffff]: 1 change artifact: 31c4f8e54e user: hobbs
2004-07-14
09:09 • Ticket [988703ffff]: 4 changes artifact: 76ce16d899 user: mistachkin
09:07 • Ticket [988703ffff]: 4 changes artifact: 61835e4080 user: mistachkin
06:41 • Ticket [988703ffff]: 4 changes artifact: 519090eecc user: mistachkin
04:41 • Ticket [988703ffff]: 5 changes artifact: f0ebb0de41 user: msofer
2004-07-11
07:07 • Ticket [988703ffff]: 4 changes artifact: c0729a60ff user: mistachkin
00:07 • New ticket [988703ffff]. artifact: c9f1f0a5dc user: mistachkin

tsdPtr->objThreadMap and data never freed in tclObj.c

Closed / Fixed988703ffffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 17 years ago
Descriptionplain2004-07-11 00:07:24
When compiled with threads and debugging, the
tsdPtr->objThreadMap hash table and it's associated
data is never freed.  This leak grows for each object
allocated and for each thread used.

A patch designed to fix this issue is attached.

Please review and commit.

Also, I believe this bug may exist in the
core-8-4-branch as well.  Perhaps this bugfix should be
backported?
mistachkinplain2004-07-11 07:07:24
File Added - 93512: bugfix.diff
msoferplain2004-07-14 04:41:43
Logged In: YES 
user_id=148712

Dropping the ball: I don't know about these issues.
mistachkinplain2004-07-14 06:41:53
Logged In: YES 
user_id=113501


Patch needs to be update, the call:

  TclFinalizeThreadObjDebugging();

needs to be outside of the "if" block it is currently in.
mistachkinplain2004-07-14 09:07:09
File Deleted - 93512:
mistachkinplain2004-07-14 09:09:19
File Added - 93877: bug988703.diff

Logged In: YES 
user_id=113501


Patch updated. Although, now that I think about it, I'm not
sure what the "right thing" is in this case.  Can people
create a new Tcl_Obj without hitting the code that
initializes the thread storage for "tclEvent.c"?
hobbs Ticket [988703ffff]: 1 change [History diff]2004-11-18 01:11:24
hobbs Ticket [988703ffff]: 1 change [History diff]2005-05-31 09:17:28
vasiljevicplain2005-05-31 19:51:39
Logged In: YES 
user_id=95086

As I see, the core-8-4-branch does not track the debugging info
about objects created in a thread, hence there is nothing to backport.

Yes, it seems that this table is never garbage collected and this will
result in memory leaks with debugging turned on. It is therefore
correct to garbage-collect this table on thread exit. I do not think that
we should ask ourselves about this being the "right thing". If the table
is allocated, it must be garbage collected, regardless how or from whom
it got created and/or under which circumstances. 

I will have to study this in some more detail because this is the first
time I'm looking at that code, It must have beed added lately and I 
have obviously missed that.

Do you see any particular hidden danger here. I do not at the first 
glance.
mistachkinplain2007-06-19 12:58:59
File Deleted - 93877:
mistachkinplain2007-06-19 13:33:19
File Added - 233642: objThreadMap3.diff

Logged In: YES 
user_id=113501
Originator: YES


Here is the updated and tested patch against HEAD.  It corrects the leak(s) and enhances the objThreadMap to track file and line information per object when TCL_THREADS and TCL_MEM_DEBUG are enabled.  With this patch, the threaded debug build (on Windows) now leaks zero bytes.

File Added: objThreadMap3.diff
mistachkinplain2009-03-15 12:12:31
File Added - 317876: TclDbInitNewObj.zip
mistachkinplain2009-03-15 12:12:33
File Deleted - 233642: 


Updated patch to HEAD, cleaned up, and added the ability to dump the active
objects.  The patch cannot be committed "as is" without a TIP because it
adds an "objs" sub-command to [memory].  This functionality is extremely
useful for debugging Tcl_Obj leaks; therefore, I'm willing to entertain
alternative approaches on exposing it that could make it into 8.6.

File Added: TclDbInitNewObj.zip
mistachkin Ticket [988703ffff]: 1 change [History diff]2009-03-15 12:36:14
dkfplain2009-03-15 15:37:23
I could survive changing [memory] without a TIP; it's not a tool that production code will be using (too much of a performance penalty). Indeed, if we were doing it now I bet it would go in tcl::unsupported
dkf Ticket [988703ffff]: 1 change [History diff]2009-06-18 15:42:51
dkfplain2009-06-18 16:15:35
There are a few spots where the patch doesn't brace arms of an 'if', but otherwise looks good.

Don't forget to write a bit of documentation. Feel free to do that by writing a short paragraph in here; I'm happy to patch it into docs/memory.n for you.
dkf Ticket [988703ffff]: 1 change [History diff]2009-06-18 16:15:51
dkfplain2009-06-18 16:44:08
allow_comments - 1

Committed; not bothering to backport.
mistachkinplain2009-10-18 18:22:36
Now backported to core-8-5-branch.
Log in (anonymous is fine) to add a comment.

Attachments: