Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c73511de15ea020ba5bfe6735414c287f77e1921
Ticket: 3383616fffffffffffffffffffffffffffffffff
memory leak in Tcl 8.6 for compiled locals with resolveInfo
User & Date: gneumann on 2011-08-01 10:46:11
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Tcl 8.6b2 has a memory leak when re-bytecompiling procs. The cleanup-section in function TclProcCompileProc() (in file tclProc.c) iterates over "old" compiledLocals and frees it blindly (see below: ckfree(toFree)). However, the resolveInfo can contain data, and might point to to a deleteProc. i discovered the issue when using resolvers. The cleanup is handled correctly in TclProcCleanupProc() and in a similar way in InitResolvedLocals(). To ease maintenance one should factor out a common small c-function to handle the cleanup of compiled locals. The issue does not exist in Tcl 8.5.*. The following patch fixes the issue, and runs clean with valgrind.
    
    -gustaf neumann
    PS: i have submitted the bugreport already yesterday, but it did not show up so far. Maybe, there is something broken at sourceforge, so i try again. I hope, this will not generate a duplicate entry.
    
    --- generic/tclProc.c-orig2011-07-31 18:16:22.000000000 +0200
    +++ generic/tclProc.c2011-07-31 18:17:05.000000000 +0200
    @@ -2063,6 +2063,15 @@
     CompiledLocal *toFree = clPtr;
     
     clPtr = clPtr->nextPtr;
    +
    +if (toFree->resolveInfo) {
    +    if (toFree->resolveInfo->deleteProc) {
    +toFree->resolveInfo->deleteProc(toFree->resolveInfo);
    +    } else {
    +ckfree(toFree->resolveInfo);
    +    }
    +}
    +
     ckfree(toFree);
         }
         procPtr->numCompiledLocals = procPtr->numArgs;
    
    
  4. foundin changed to: "obsolete: 8.6b2"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "gneumann"
  10. subsystem changed to: "None"
  11. title changed to:
    memory leak in Tcl 8.6 for compiled locals with resolveInfo
    
  12. type changed to: "Bug"