Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 18011f15424c197c0d615c91f2743da2474226b1
Ticket: 733221ffffffffffffffffffffffffffffffffff
various memory leaks...
User & Date: mistachkin on 2003-05-06 12:07:49
Changes

  1. assignee changed to: "hobbs"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    --------
    
    generic/tclDate.c
    
    1. Shouldn't this file be using ckalloc/ckrealloc?
    2. The following variables are allocated and are 
    never freed:
    
    int *TclDates;
    YYSTYPE *TclDatev;
    
    --------
    
    win/tclAppInit.c, line 269:
    
        argSpace = (char *) Tcl_Alloc(
        (unsigned) (size * sizeof(char *) + strlen
    (cmdLine) + 1));
    
    1. Shouldn't this also be ckalloc?
    2. This is a local variable in the function.
    3. This memory is never freed.
    
    --------
    
    tools/encoding/txt2enc.c
    
    1. Memory allocated via malloc on line #181 and 
    #204 is never freed.
    2. Since this is a stand-alone utility, it should be 
    fairly trivial to fix these leaks with the following 
    code before "return 0" on line #243:
    
        for (hi = 0; hi < 256; hi++) {
    if (toUnicode[hi] != NULL) {
        free(toUnicode[hi]);
                toUnicode[hi] = NULL;
    }
        }
    
    --------
    
    generic/tclThreadAlloc.c
    
    1. We have the static file variables:
    
    static Tcl_Mutex *listLockPtr;
    static Tcl_Mutex *objLockPtr;
    
    2. They are allocated via TclpNewAllocMutex, which 
    BOTH allocates memory via malloc AND calls 
    InitializeCriticalSection on the contained critical 
    section.
    
    3. Neither the block of memory nor the critical 
    section are ever freed.
    
    4. There needs to be a new function in 
    tclThreadAlloc.c, 
    called "TclFinalizeThreadAllocSubsystem", that 
    frees these mutexes (probably by calling an 
    appropriate platform specific func, yet to be 
    created, perhaps called "TclpNewFreeMutex") and 
    then calls the "TclpFinalizeThreadAllocSubsystem" 
    function for the platform specific cleanup (i've 
    created the Win32 version of this function in my 
    new patch #731356).
    
    5. Another leak (see SF bug #731754, fixed in my 
    patch #731356) involves this code, near line #279:
    
    #ifdef WIN32
        TlsFree((DWORD) cachePtr);
    #else
        free(cachePtr);
    #endif
    
    The above code is entirely incorrect for Win32.  I 
    believe it should always be "free(cachePtr);" as 
    cachePtr is NOT a TLS index, it is a block of 
    memory.
    
    6. Yet another leak (also fixed in my patch 
    #731356) involves freeing the actual TLS index 
    used by the threaded memory allocator (what the 
    above incorrect code was TRYING and failing to do).
    
    --------
    
    
  4. foundin changed to: "None"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "mistachkin"
  9. subsystem changed to: "41. Memory Allocation"
  10. title changed to: "various memory leaks..."
  11. type changed to: "Bug"