Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-12
17:12 • Closed ticket [1710825fff]: "Still reachable" memory leaks in Tcl I/O ... artifact: b52b2e85db user: serhiy.storchaka
2011-09-24
05:19 • Ticket [1710825fff]: 4 changes artifact: 25aa3ddd3b user: ferrieux
2007-05-11
01:47 • Open ticket [1710825fff]. artifact: 8271b8b901 user: dgp
2007-05-02
11:44 • Closed ticket [1710825fff]. artifact: df2ebd39a7 user: kennykb
04:18 • Add attachment ioleak.patch to ticket [1710825fff] artifact: 5457b9292e user: kennykb
04:18 • Ticket [1710825fff] "Still reachable" memory leaks in Tcl I/O subsyste... artifact: 19f6366cac user: kennykb
2007-05-01
21:18 • New ticket [1710825fff]. artifact: 97aca1b73d user: kennykb

"Still reachable" memory leaks in Tcl I/O subsystem

Closed / Fixed1710825fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 51 days ago
Descriptionplain2007-05-01 21:18:02
I'm tracking down places where Tcl leaves memory "still reachable" on exit.  For reference, I'm adding

proc exit args {}

at the end of tests/all.tcl, so that the main interp will be properly destroyed.

I find two major sources of leakage:

(1) In a non-threaded build, TSD blocks are never
    freed.  This problem happens simply because the
    #ifdef's in TclFinalizeSynchronization are
    misplaced.
(2) TclFinalizeIOSubsystem never gets past closing the
    first still-open channel, because by the time
    control returns from Tcl_Close, the
    'nextCSPtr' field in the channel state has
    been cleared.

The attach patch, for your review, appears to close
both leaks and introduces no new failures in 'make test'.
Sorry that it's so hard to read; the indentation changes
get in the way a bit.
kennykbplain2007-05-02 04:18:02
File Added - 227417: ioleak.patch
kennykb Closed ticket [1710825fff]. [History diff]2007-05-02 11:44:37
dgpplain2007-05-11 01:47:01
Logged In: YES 
user_id=80530
Originator: NO


Re-open;  Request a review to
see if any part of this needs
backporting for 8.4.15.
ferrieuxplain2011-09-24 05:19:18
Is that still valid after recent leak hunts ?
serhiy.storchakawiki2026-10-12 17:12:56

Both issues were fixed in [41c23d142b] (8.5a6). With 9.1, valgrind shows no leaks from channels left open at exit; what remains is due to [exit] not unwinding the stack, see [3400944].

Log in (anonymous is fine) to add a comment.

Attachments: