Skip to content
Tcl Source Code View Ticket
Login

View Ticket

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

Closed / Fixed1710825fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 52 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: