Skip to content
Tcl Source Code History Of Ticket 3290426fffffffff
Login

History Of Ticket 3290426fffffffff

Artifacts Associated With Ticket 3290426fffffffff

  1. Ticket change [153cba11e3] (rid 124538) by juddgilbert on 2011-04-20 16:06:53:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Hello,
      
      I am seeing a memory leak using Valgrind with C++ and TCL 8.6.b1. Here
      is my example code:
      
      #include <stdio.h>
      #include <stdlib.h>
      #include "tcl.h"
      
      int main(int argc, char* argv[])
      {
        Tcl_Interp* MainInterp;
        printf("creating interp...\n");
        MainInterp = Tcl_CreateInterp();
        printf("deleting interp...\n");
        Tcl_DeleteInterp(MainInterp);
        printf("finalizing...\n");
        Tcl_Finalize();
        printf("exiting...\n");
        exit(0);
      
      }
      
      To compile I am doing the following:
      
       ../auxil/gcc-4.3.3/bin/g++ -I../auxil/tcl8.6b1/include src/
      tcltest.cpp -ltcl8.6 -L../auxil/tcl8.6b1/lib
      
      When running the output of this program using the Valgrind mem
      checker :
      
      valgrind --leak-check=full ./a.out
      
      I get the following output:
      
      ==18208== Memcheck, a memory error detector
      ==18208== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et
      al.
      ==18208== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright
      info
      ==18208== Command: ./a.out
      ==18208==
      creating interp...
      deleting interp...
      finalizing...
      exiting...
      ==18208== Invalid free() / delete / delete[]
      ==18208==    at 0x400551D: free (vg_replace_malloc.c:325)
      ==18208==    by 0x475C7D2D: ??? (in /lib/libc-2.5.so)
      ==18208==    by 0x475C78A6: ??? (in /lib/libc-2.5.so)
      ==18208==    by 0x40013B2: _vgnU_freeres (vg_preloaded.c:62)
      ==18208==    by 0x475485A3: _Exit (in /lib/libc-2.5.so)
      ==18208==    by 0x8048668: main (in /home/jgilbert/dev/src/tcs/a.out)
      ==18208==  Address 0x4135b18 is not stack'd, malloc'd or (recently)
      free'd
      ==18208==
      ==18208==
      ==18208== HEAP SUMMARY:
      ==18208==     in use at exit: 14,400 bytes in 6 blocks
      ==18208==   total heap usage: 2,190 allocs, 2,185 frees, 106,298 bytes
      allocated
      ==18208==
      ==18208== 14,400 (2,400 direct, 12,000 indirect) bytes in 1 blocks are
      definitely lost in loss record 6 of 6
      ==18208==    at 0x4005903: malloc (vg_replace_malloc.c:195)
      ==18208==    by 0x402ADAC: TclpAlloc (in /home/militho/dev/src/auxil/
      tcl8.6b1/lib/libtcl8.6.so)
      ==18208==    by 0x4038094: Tcl_Alloc (in /home/militho/dev/src/auxil/
      tcl8.6b1/lib/libtcl8.6.so)
      ==18208==    by 0x40B93FE: TclAllocateFreeObjects (in /home/militho/
      dev/src/auxil/tcl8.6b1/lib/libtcl8.6.so)
      ==18208==    by 0x40B9694: Tcl_NewObj (in /home/militho/dev/src/auxil/
      tcl8.6b1/lib/libtcl8.6.so)
      ==18208==    by 0x4032D4E: Tcl_CreateInterp (in /home/militho/dev/src/
      auxil/tcl8.6b1/lib/libtcl8.6.so)
      ==18208==    by 0x8048625: main (in /home/jgilbert/dev/src/tcs/a.out)
      ==18208==
      ==18208== LEAK SUMMARY:
      ==18208==    definitely lost: 2,400 bytes in 1 blocks
      ==18208==    indirectly lost: 12,000 bytes in 5 blocks
      ==18208==      possibly lost: 0 bytes in 0 blocks
      ==18208==    still reachable: 0 bytes in 0 blocks
      ==18208==         suppressed: 0 bytes in 0 blocks
      ==18208==
      ==18208== For counts of detected and suppressed errors, rerun with: -v
      ==18208== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 25 from
      10)
      
      Some things I've noticed:
      
      1. Without the call to Tcl_Finalize() I get even more errors.
      2. If I change exit(0) to return(0) there is no change.
      3. Simply linking with the TCL library causes the first message about
      the invalid free/delete, with all code commented out except exit(0).
      
      Has anyone else seen this? I'm wondering if this is a legitimate
      memory leak in TCL 8.6b1. I searched bugs using the string "memory leak Tcl_CreateIterp" and found some similar bugs, but didn't see any solutions that really applied for me.
      
      I am not sure this matters, but I am using RHEL kernel 2.6.18-8.el5 .
      
      Thanks! 
      
    4. foundin initialized to: "obsolete: 8.6b1"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "juddgilbert"
    10. subsystem initialized to: "None"
    11. title initialized to: "Valgrind reports TCL memory leak "
    12. type initialized to: "Bug"
  2. Ticket change [0e09b2b8e7] (rid 94539) by ferrieux on 2011-04-20 23:45:08:

    1. closedate changed to: "2011-04-20T16:45:08"
    2. closer changed to: "ferrieux"
    3. icomment:
      Sounds like a dup of 2919042.
      Please confirm by applying the patch there.
      
      
    4. login: "ferrieux"
    5. mimetype: "text/plain"
    6. resolution changed to: "Duplicate"
    7. status changed to: "Pending"
    8. username: "ferrieux"
  3. Ticket change [b805ffa1ef] (rid 128901) by juddgilbert on 2011-04-21 02:27:08:

    1. icomment:
      I agree it sounds like the same bug. I tried all 3 patches individually, none worked. Did a "make clean all install" between applying each one. Reversed changes in between applying each one. I still get the same error output.
      
      
    2. login: "juddgilbert"
    3. mimetype: "text/plain"
    4. resolution changed to: "None"
    5. status changed to: "Open"
    6. username: "juddgilbert"
  4. Ticket change [468d7f8923] (rid 99538) by ferrieux on 2011-04-21 03:03:50:

    1. icomment:
      Oops, sorry, HEAD had drifted by mundane things (comment layout, and (char *) casts in ckfree... sigh).
      I have updated the patch there, please retry.
      I think this will remove most of the leaks, but in my case a few remained. See my comment of 2009-12-22 15:24:52 CET in 2919042. If you observe similar things, please close the present bugreport and followup on the older one.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  5. Ticket change [69d1135890] (rid 128043) by juddgilbert on 2011-04-21 05:41:02:

    1. icomment:
      Current patch val4.patch is busted I believe. I added all my notes about this to original bug 2919042
      
      
    2. login: "juddgilbert"
    3. mimetype: "text/plain"
    4. username: "juddgilbert"
  6. Ticket change [1bea51dfb7] (rid 210946) by chrstphrchvz on 2023-03-26 11:33:47:

    1. closedate changed to: "2460029.98180072"
    2. closer changed to: "chrstphrchvz"
    3. comment changed to:
      Hello,
      
      I am seeing a memory leak using Valgrind with C++ and TCL 8.6.b1. Here
      is my example code:
      
      #include <stdio.h>
      #include <stdlib.h>
      #include "tcl.h"
      
      int main(int argc, char* argv[])
      {
        Tcl_Interp* MainInterp;
        printf("creating interp...\n");
        MainInterp = Tcl_CreateInterp();
        printf("deleting interp...\n");
        Tcl_DeleteInterp(MainInterp);
        printf("finalizing...\n");
        Tcl_Finalize();
        printf("exiting...\n");
        exit(0);
      
      }
      
      To compile I am doing the following:
      
       ../auxil/gcc-4.3.3/bin/g++ -I../auxil/tcl8.6b1/include src/
      tcltest.cpp -ltcl8.6 -L../auxil/tcl8.6b1/lib
      
      When running the output of this program using the Valgrind mem
      checker :
      
      valgrind --leak-check=full ./a.out
      
      I get the following output:
      
      ==18208== Memcheck, a memory error detector
      ==18208== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et
      al.
      ==18208== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright
      info
      ==18208== Command: ./a.out
      ==18208==
      creating interp...
      deleting interp...
      finalizing...
      exiting...
      ==18208== Invalid free() / delete / delete[]
      ==18208==    at 0x400551D: free (vg_replace_malloc.c:325)
      ==18208==    by 0x475C7D2D: ??? (in /lib/libc-2.5.so)
      ==18208==    by 0x475C78A6: ??? (in /lib/libc-2.5.so)
      ==18208==    by 0x40013B2: _vgnU_freeres (vg_preloaded.c:62)
      ==18208==    by 0x475485A3: _Exit (in /lib/libc-2.5.so)
      ==18208==    by 0x8048668: main (in /home/jgilbert/dev/src/tcs/a.out)
      ==18208==  Address 0x4135b18 is not stack'd, malloc'd or (recently)
      free'd
      ==18208==
      ==18208==
      ==18208== HEAP SUMMARY:
      ==18208==     in use at exit: 14,400 bytes in 6 blocks
      ==18208==   total heap usage: 2,190 allocs, 2,185 frees, 106,298 bytes
      allocated
      ==18208==
      ==18208== 14,400 (2,400 direct, 12,000 indirect) bytes in 1 blocks are
      definitely lost in loss record 6 of 6
      ==18208==    at 0x4005903: malloc (vg_replace_malloc.c:195)
      ==18208==    by 0x402ADAC: TclpAlloc (in /home/militho/dev/src/auxil/
      tcl8.6b1/lib/libtcl8.6.so)
      ==18208==    by 0x4038094: Tcl_Alloc (in /home/militho/dev/src/auxil/
      tcl8.6b1/lib/libtcl8.6.so)
      ==18208==    by 0x40B93FE: TclAllocateFreeObjects (in /home/militho/
      dev/src/auxil/tcl8.6b1/lib/libtcl8.6.so)
      ==18208==    by 0x40B9694: Tcl_NewObj (in /home/militho/dev/src/auxil/
      tcl8.6b1/lib/libtcl8.6.so)
      ==18208==    by 0x4032D4E: Tcl_CreateInterp (in /home/militho/dev/src/
      auxil/tcl8.6b1/lib/libtcl8.6.so)
      ==18208==    by 0x8048625: main (in /home/jgilbert/dev/src/tcs/a.out)
      ==18208==
      ==18208== LEAK SUMMARY:
      ==18208==    definitely lost: 2,400 bytes in 1 blocks
      ==18208==    indirectly lost: 12,000 bytes in 5 blocks
      ==18208==      possibly lost: 0 bytes in 0 blocks
      ==18208==    still reachable: 0 bytes in 0 blocks
      ==18208==         suppressed: 0 bytes in 0 blocks
      ==18208==
      ==18208== For counts of detected and suppressed errors, rerun with: -v
      ==18208== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 25 from
      10)
      
      Some things I've noticed:
      
      1. Without the call to Tcl_Finalize() I get even more errors.
      2. If I change exit(0) to return(0) there is no change.
      3. Simply linking with the TCL library causes the first message about
      the invalid free/delete, with all code commented out except exit(0).
      
      Has anyone else seen this? I'm wondering if this is a legitimate
      memory leak in TCL 8.6b1. I searched bugs using the string "memory leak Tcl_CreateIterp" and found some similar bugs, but didn't see any solutions that really applied for me.
      
      I am not sure this matters, but I am using RHEL kernel 2.6.18-8.el5 .
      
      Thanks!
      
    4. icomment: "Duplicate of [2919042]"
    5. login: "chrstphrchvz"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Duplicate"
    8. severity changed to: "Minor"
    9. status changed to: "Closed"
    10. title changed to: "Valgrind reports TCL memory leak"