Artifacts Associated With Ticket 3394654fffffffffffffffffffffffffffffffff
Ticket change [71be4bf5e4] (rid 100739) by dgp on 2011-08-19 16:13:48:
- assignee initialized to: "andreas_kupries"
- cmimetype initialized to: "text/plain"
- comment initialized to:
$ cat leak.tcl set nested 0 proc foo {fd args} { switch -exact [lindex $args 0] { initialize {return {initialize finalize read write}} finalize {return {}} } global nested if {$nested} { return } set nested 1 chan pop $fd } set b [open /dev/null w] set c [chan push $b [list foo $b]] puts $c a flush $c close $c $ valgrind --leak-check=yes ./tclsh leak.tcl ... ==27262== 8,577 (16 direct, 8,561 indirect) bytes in 1 blocks are definitely lost in loss record 20 of 20 ==27262== at 0x4A05E1C: malloc (vg_replace_malloc.c:195) ==27262== by 0x482844: Tcl_Alloc (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x453534: TclpOpenFileChannel (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x42066F: Tcl_FSOpenFileChannel (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x4E0073: Tcl_OpenObjCmd (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x47CF39: TclNREvalObjv (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x47D583: Tcl_EvalObjv (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x47DFF3: TclEvalEx (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x42CE58: TclSubstTokens (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x47D8BF: TclEvalEx (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x47E325: Tcl_EvalEx (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x421169: Tcl_FSEvalFileEx (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) - foundin initialized to: "obsolete: 8.6b2"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "26. Channel Transforms"
- title initialized to: "leak due to non closing base of stacked channels"
- type initialized to: "Bug"
Ticket change [5c8efe195f] (rid 115321) by dgp on 2011-08-19 23:17:40:
- icomment:
The ClientData of channel $c is leaking because [close $c] is not actually closing the channel (not calling CloseChannel(), thus not calling the closeProc of the driver). This is not happening because FlushChannel sees the channel as not having an empty buffer at "curOutPtr" and for reasons I don't understand, takes that as an indication not to make the close. If I disable that test in FlushChannel(), the leak goes away.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [a9f680a1cb] (rid 99241) by dgp on 2011-08-19 23:29:13:
- icomment:
The need for this "only empty buffers can permit a close" test is not demonstrated by the test suite, FWIW.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [b8a61f98b6] (rid 128999) by dgp on 2011-08-19 23:30:49:
- icomment:
That said, I suspect the real bug here is that the buffers in fact should be empty at this point, and whatever bug is causing it not to be empty is likely a common cause of Bug 3393276
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [c0b6578fb8] (rid 102462) by dgp on 2011-08-20 00:28:40:
- icomment:
When the buffer fails to test as empty, it claims to be holding -2 bytes.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [b865861203] (rid 128960) by dgp on 2011-08-20 01:43:20:
- icomment:
FlushChannel needs to account for the possibility that the ChanWrite() call might recycle the buffer our from under us. Adding a test IsBufferEmpty(.) at the right place is effective.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [b772805ff8] (rid 125601) by dgp on 2011-08-20 02:07:20:
- closedate changed to: "2011-08-19T19:07:20"
- closer changed to: "dgp"
- icomment:
allow_comments - 1 fixed in trunk
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "dgp"
Ticket change [19cb6a134a] (rid 122850) by dgp on 2011-08-20 02:07:31:
- assignee changed to: "dgp"
Ticket change [e389045189] (rid 137997) by dgp on 2014-05-08 15:59:59:
- closedate changed to: "2456786.16665822"
- comment changed to:
$ cat leak.tcl set nested 0 proc foo {fd args} { switch -exact [lindex $args 0] { initialize {return {initialize finalize read write}} finalize {return {}} } global nested if {$nested} { return } set nested 1 chan pop $fd } set b [open /dev/null w] set c [chan push $b [list foo $b]] puts $c a flush $c close $c $ valgrind --leak-check=yes ./tclsh leak.tcl ... ==27262== 8,577 (16 direct, 8,561 indirect) bytes in 1 blocks are definitely lost in loss record 20 of 20 ==27262== at 0x4A05E1C: malloc (vg_replace_malloc.c:195) ==27262== by 0x482844: Tcl_Alloc (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x453534: TclpOpenFileChannel (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x42066F: Tcl_FSOpenFileChannel (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x4E0073: Tcl_OpenObjCmd (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x47CF39: TclNREvalObjv (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x47D583: Tcl_EvalObjv (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x47DFF3: TclEvalEx (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x42CE58: TclSubstTokens (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x47D8BF: TclEvalEx (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x47E325: Tcl_EvalEx (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) ==27262== by 0x421169: Tcl_FSEvalFileEx (in /local/tmp/dgp/fossil/tcl-only/valgrind/tclsh) - icomment:
Turns out this was a band-aid solution, and the design troubles with sharing of ChannelBuffers ran much deeper. Now the band-aid is corrupting the actual fix. Removing it allows the real fix (refcounting ChannelBuffers) to function properly.
- login: "dgp"
- mimetype: "text/plain"
- severity changed to: "Minor"