Artifacts Associated With Ticket 983660ffffffffff
Ticket change [5a2cd8306e] (rid 118096) by pspjuth on 2004-07-01 20:31:40:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
If I repeat this: interp create testinterp catch {testinterp eval {lisx}} interp delete testinterp memory increases with each iteration. According to [memory info] 25 packets, 709 bytes, is lost each iteration. If I replace "lisx" with "list" so no error occurs, nothing leaks. testinterp eval {catch lisx} leaks as well This is run with current CVS HEAD on a WinXP machine. - foundin initialized to: "obsolete: 8.5a2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "pspjuth"
- subsystem initialized to: "None"
- title initialized to: "Mem leak when getting error"
- type initialized to: "Bug"
Ticket change [7b78f80c6e] (rid 90519) by hobbs on 2004-07-02 04:25:37:
- assignee changed to: "msofer"
Ticket change [a852cbe4ae] (rid 98960) by msofer on 2004-07-02 05:06:18:
- icomment:
Logged In: YES user_id=148712 Oh my, leak confirmed in current HEAD under linux, no MEM_DEBUG (*). It is not present in 8.4.5. (*) method: infinite loop while 1 { interp create testinterp catch {testinterp eval {lisx}} interp delete testinterp after 100 } watched in top. - login: "msofer"
- mimetype: "text/plain"
- priority changed to: "9 Immediate"
- username: "msofer"
- icomment:
Ticket change [5eef97156d] (rid 115723) by dgp on 2004-07-02 20:56:30:
- icomment:
Logged In: YES user_id=80530 Change "lisx" to "error foo" and the leak goes away. Thus, I suspect the [unknown]/auto-loader instead of [return]/$::errorInfo.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [cb68d6c9a0] (rid 95510) by dgp on 2004-07-02 20:58:57:
- icomment:
Logged In: YES user_id=80530 Change back to "lisx" and define [proc unknown args {}] in testinterp and the leak also goes away. - login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [f67f0ff2de] (rid 130312) by dgp on 2004-07-02 21:13:37:
- icomment:
Logged In: YES user_id=80530 Define [proc unknown args {return -code error foo}] and the leak returns. suspect something in the code that calls [unknown] is not cleaning up everything when [unknown] raises an error (?) - login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [c531284b86] (rid 111956) by dgp on 2004-07-03 02:05:12:
- icomment:
Logged In: YES user_id=80530 Somehow the INST_RETURN command is involved. Still investiagting...
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [242f414aca] (rid 131070) by dgp on 2004-07-03 02:12:16:
- icomment:
Logged In: YES user_id=80530 The [unknown] appears to be a sideshow. This script should verify this is simply a leak in INST_RETURN execution: while 1 { interp create i i eval {proc foo {} {return -code break} catch {i eval foo} interp delete i } - login: "dgp"
- mimetype: "text/plain"
- subsystem changed to: "47. Bytecode Compiler"
- username: "dgp"
- icomment:
Ticket change [3f90f1dc13] (rid 121480) by msofer on 2004-07-04 05:15:56:
- icomment:
Logged In: YES user_id=148712 That script (missing a '}') leaks too
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [9e55e03eb4] (rid 96456) by msofer on 2004-07-04 06:15:03:
- icomment:
Logged In: YES user_id=148712 The leak, according to valgrind: 48 bytes in 2 blocks are definitely lost in loss record 1 of 2 at 0x3C01F40D: malloc (vg_replace_malloc.c:105) by 0x80FF82C: TclpAlloc (tclAlloc.c:677) by 0x809B274: Tcl_Alloc (tclCkalloc.c:1001) by 0x80715BF: Tcl_DuplicateObj (tclObj.c:862) by 0x80A7357: TclMergeReturnOptions (tclCmdMZ.c:968) by 0x80B3CD3: TclCompileReturnCmd (tclCompCmds.c:2520) by 0x80BB16E: TclCompileScript (tclCompile.c:1072) by 0x80BA540: TclSetByteCodeFromAny (tclCompile.c:401) by 0x80BA748: SetByteCodeFromAny (tclCompile.c:499) by 0x807B46C: TclProcCompileProc (tclProc.c:1216)
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [7cb360a7ce] (rid 97126) by msofer on 2004-07-04 07:19:17:
- icomment:
Logged In: YES user_id=148712 Comments that are probably relevant: (1) in tclLiteral.c (l 448, TclAddLiteralObj): the literalis *not* added to the literal tables, only to the literal array (2) in tclCompile.c (l 661, TclCleanupByteCode): if the interp is marked as deleted, it will already have cleaned up all literals so we refrain from doing it again (3) in tclBasic.c (l 1112, DeleteInterpProc): interp deletion cleans up all literals in the literal table So it looks like the returnOptions added to the literal array (but not to the table) at line 2593 in tclCompCmds.c (TclCompileReturnCmd) is bypassed by the cleanup process.
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [52a884df16] (rid 126354) by msofer on 2004-07-04 07:34:11:
- icomment:
Logged In: YES user_id=148712 Indeed - inserting i eval {rename foo {}} before deleting i removes the leak. Note that this is a more general bug, the returnOpts is just a trigger. Every non-shared literal in a proc body will be leaked if the proc is not explicitly deleted before the interp. Amazing that this hasn't been detected in usage of precompiled proc bodies (proComp)! - login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [a4a5f794bf] (rid 110239) by msofer on 2004-07-04 09:30:48:
- icomment:
Logged In: YES user_id=148712 Mmhh .. diagnose not 100% accurate yet
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [859da53e57] (rid 131344) by msofer on 2004-07-04 21:41:47:
- icomment:
Logged In: YES user_id=148712 The bug is apparently in the freeing of non-shared literal objects; note that TclCompileReturnCmd is the only caller of TclAddLiteralObj in the core, and that TclHideLiteral is not used at all in the core.
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [c31779944c] (rid 111596) by msofer on 2004-07-05 17:25:20:
- icomment:
Logged In: YES user_id=148712 Rewinding, back to square 1: the bug does seem to be in the handling of the return options, as storing them as a shared literal does not plug the leak. This was tested by replacing TclAddLiteralObj with TclRegisterNewLiteral. Somehow, the proc body is not being cleaned up properly on interp deletion. This is determined by noticing that either of i eval {rename foo {}} i eval {proc foo {} {}} before deleting the interp plugs the leak. The leak does not appear with other literals. - login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [5d78c4cbef] (rid 115469) by msofer on 2004-07-06 05:48:01:
- icomment:
Logged In: YES user_id=148712 Oh boy - finally found it. DeleteInterpProc was releasing the interp's handle before tearing down the global namespace, so that TclCleanupByteCode was being called with a NULL interp. This prevented the proper freeing of literals. The current solution may have an impact on interp deletion speed; leaving open so that I remember to look for more a more efficient solution.
- login: "msofer"
- mimetype: "text/plain"
- priority changed to: "5 Medium"
- resolution changed to: "Fixed"
- title changed to: "Leak of unshared literals at interp deletion"
- username: "msofer"
- icomment:
Ticket change [eff31e1243] (rid 109086) by msofer on 2004-07-08 05:47:14:
- icomment:
Logged In: YES user_id=148712 The performance issue is: * before the patch, the interp deletion loops through the interp's literal table releasing all literals in the interp (in a suboptimal manner, but just one loop and with no hashing) * after the patch, every proc in the interp will loop through its own literal array releasing the literals - and doing a hash lookup for each one. No literals remain for the overall interp deletion loop. A possible solution is to register unshared literals in the interp's table with refCount -1 (to signal that they should not be shared). Note that this is actually specified in the comments (tclInt.h line 921), but not done in the code.
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [fc8df42df6] (rid 108257) by msofer on 2004-07-09 01:49:31:
- closedate changed to: "2004-07-08T18:49:31"
- closer changed to: "msofer"
- icomment:
Logged In: YES user_id=148712 Fix modified: at interp deletion, each bytecodeobject releases its literal references but does not update the dying literal table; in this way, there are is no hashing involved. When TclDeleteLiteralTable is called, the only remaining references are those in the table itself.
- login: "msofer"
- mimetype: "text/plain"
- status changed to: "Closed"
- username: "msofer"
Ticket change [f0e3664731] (rid 109274) by msofer on 2004-07-15 19:20:29:
- priority changed to: "9 Immediate"
- resolution changed to: "None"
- status changed to: "Open"
Ticket change [59fbf75639] (rid 118063) by msofer on 2004-07-15 19:20:30:
- icomment:
Logged In: YES user_id=148712 Reopening: the fix is buggy, compile-12.1 is failing on the current HEAD (compiled with --disable-shared --enable-symbols=all, threaded and uthreaded builds). The new logic at interp deletion is bypassing the special code for empty bytecodes (see also bug 467523).
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [251d826026] (rid 131230) by msofer on 2004-07-16 00:44:54:
- closedate changed to: "2004-07-15T17:44:54"
- closer changed to: "msofer"
- icomment:
Logged In: YES user_id=148712 Closing this ticket, bug 467523 that had been rsurrected is now solved.
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "msofer"