Ticket UUID: | c7d0bc9a549714e031971ea60e6b0392b51d0d75 | |||
Title: | Newly introduced unshared (local-only) literals from cmd resolvers cause Tcl_Obj leaks | |||
Type: | Bug | Version: | core-8-6-branch | |
Submitter: | mr_calvin | Created on: | 2016-09-15 10:41:54 | |
Subsystem: | 45. Parsing and Eval | Assigned To: | jan.nijtmans | |
Priority: | 5 Medium | Severity: | Critical | |
Status: | Closed | Last Modified: | 2016-09-21 09:30:54 | |
Resolution: | Fixed | Closed By: | jan.nijtmans | |
Closed on: | 2016-09-21 09:30:54 | |||
Description: |
The recently applied changes in response to http://core.tcl.tk/tcl/tktview?name=d4e7780ca1 open up a Tcl_Obj leak because refcounting was not adjusted accordingly, e.g.: ==28916== 93 (48 direct, 45 indirect) bytes in 1 blocks are definitely lost in loss record 35 of 64 ==28916== at 0x4C2BBAD: malloc (vg_replace_malloc.c:299) ==28916== by 0x50ED4F2: TclpAlloc (tclAlloc.c:699) ==28916== by 0x5104DDC: Tcl_Alloc (tclCkalloc.c:1059) ==28916== by 0x521525E: TclCreateLiteral (tclLiteral.c:236) ==28916== by 0x52155F9: TclRegisterLiteral (tclLiteral.c:445) ==28916== by 0x51A0F99: CompileCmdLiteral (tclCompile.c:1794) ==28916== by 0x51A1242: TclCompileInvocation (tclCompile.c:1814) ==28916== by 0x51A252B: CompileCommandTokens (tclCompile.c:2074) ==28916== by 0x51A2940: TclCompileScript (tclCompile.c:2193) ==28916== by 0x51A3BE6: TclCompileTokens (tclCompile.c:2442) ==28916== by 0x5157AFC: TclCompileNamespaceTailCmd (tclCompCmdsGR.c:2055) ==28916== by 0x51C2F67: TclAttemptCompileProc (tclEnsemble.c:3212) The literal Tcl_Obj kept being bumped to reflect a global literal reference unconditionally, i.e., even when it is treated as unshared, local-only literal in subsequent steps. The fix is to move Tcl_IncrRefCount(objPtr) further down in TclCreateLiteral(), when it becomes certain that the literal actually becomes global. I would also suggest adjusting the in-code comments slightly, to better reflect the modified literal handling. See attached path for both. | |||
User Comments: |
jan.nijtmans added on 2016-09-21 09:30:54:
Better inline comment handled by "trunk" now. Closing gustafn2 added on 2016-09-21 09:08:06: The modified inline comments reflect the differentiation between global (shared) and unshared literals properly. jan.nijtmans added on 2016-09-16 09:09:50: Fix committed to core-8-6-branch and trunk. In-code oomments not taken into account yet, I'll leave that in the hands of Gustaf. Therefore keeping this ticket open for the moment. gustafn2 added on 2016-09-16 07:51:08: The fix is correct. i did some larger tests (naviserver, valgrind, ...) everything looks ok. jan.nijtmans added on 2016-09-15 13:27:56: Proposed fix committed to branch bug-c7d0bc9a549714e0. Appears fully valid to me. Asking feedback from Gustaf Neumann. mr_calvin added on 2016-09-15 10:43:24: Assigned to Jan, because he also sponsored the original patch. |
Attachments:
- unsharedLiteral.patch [download] added by mr_calvin on 2016-09-15 10:42:12. [details]