flightaware / Tcl-bounties

Bounty program for improvements to Tcl and certain Tcl packages
104 stars 8 forks source link

Memory Leak in tclIO.c #40

Closed bsassone closed 1 year ago

bsassone commented 2 years ago

Not sure if this is the correct forum for this, but I'll give it a shot.

I'm seeing a significant memory leak that seems to be caused by Tcl's puts command.

In the Write function defined in generic/tclIO.c, it appears that the ref count for the ChannelBuffer pointed to by *bufPtr will never reach 0 and will thus leak memory.

When AllocChannelBuffer is called, it sets the ref count to 1. PreserveChannelBuffer is then called and increases it to 2. There will only be one call to ReleaseChannelBuffer before bufPtr goes out of scope leaving the ref count at 1.

Maybe I'm missing something about how ref counts are supposed to be used and if so, I'd appreciate some guidance.

Thanks! Brian

wrenashe commented 2 years ago

https://core.tcl-lang.org/tcl/ticket here?

resuna commented 2 years ago

I would bring it up on the #tcl channel on chat.freenode.net

bovine commented 1 year ago

Closing, since this is not the proper place to report bugs.