Skip to content
Tcl Source Code Artifact [153cba11e3]
Login

Artifact [153cba11e3]

Artifact 153cba11e3eb03f89001c0072a6f478beaadbe3f:

Ticket change [153cba11e3] - New ticket [3290426fffffffff|3290426fff] <i>Valgrind reports TCL memory leak </i>. by juddgilbert on 2011-04-20 16:06:53.
D 2011-04-20T16:06:53
J assignee nobody
J cmimetype text/plain
J comment Hello,\n\nI\sam\sseeing\sa\smemory\sleak\susing\sValgrind\swith\sC++\sand\sTCL\s8.6.b1.\sHere\nis\smy\sexample\scode:\n\n#include\s<stdio.h>\n#include\s<stdlib.h>\n#include\s"tcl.h"\n\nint\smain(int\sargc,\schar*\sargv[])\n{\n\s\sTcl_Interp*\sMainInterp;\n\s\sprintf("creating\sinterp...\\n");\n\s\sMainInterp\s=\sTcl_CreateInterp();\n\s\sprintf("deleting\sinterp...\\n");\n\s\sTcl_DeleteInterp(MainInterp);\n\s\sprintf("finalizing...\\n");\n\s\sTcl_Finalize();\n\s\sprintf("exiting...\\n");\n\s\sexit(0);\n\n}\n\nTo\scompile\sI\sam\sdoing\sthe\sfollowing:\n\n\s../auxil/gcc-4.3.3/bin/g++\s-I../auxil/tcl8.6b1/include\ssrc/\ntcltest.cpp\s-ltcl8.6\s-L../auxil/tcl8.6b1/lib\n\nWhen\srunning\sthe\soutput\sof\sthis\sprogram\susing\sthe\sValgrind\smem\nchecker\s:\n\nvalgrind\s--leak-check=full\s./a.out\n\nI\sget\sthe\sfollowing\soutput:\n\n==18208==\sMemcheck,\sa\smemory\serror\sdetector\n==18208==\sCopyright\s(C)\s2002-2009,\sand\sGNU\sGPL'd,\sby\sJulian\sSeward\set\nal.\n==18208==\sUsing\sValgrind-3.5.0\sand\sLibVEX;\srerun\swith\s-h\sfor\scopyright\ninfo\n==18208==\sCommand:\s./a.out\n==18208==\ncreating\sinterp...\ndeleting\sinterp...\nfinalizing...\nexiting...\n==18208==\sInvalid\sfree()\s/\sdelete\s/\sdelete[]\n==18208==\s\s\s\sat\s0x400551D:\sfree\s(vg_replace_malloc.c:325)\n==18208==\s\s\s\sby\s0x475C7D2D:\s???\s(in\s/lib/libc-2.5.so)\n==18208==\s\s\s\sby\s0x475C78A6:\s???\s(in\s/lib/libc-2.5.so)\n==18208==\s\s\s\sby\s0x40013B2:\s_vgnU_freeres\s(vg_preloaded.c:62)\n==18208==\s\s\s\sby\s0x475485A3:\s_Exit\s(in\s/lib/libc-2.5.so)\n==18208==\s\s\s\sby\s0x8048668:\smain\s(in\s/home/jgilbert/dev/src/tcs/a.out)\n==18208==\s\sAddress\s0x4135b18\sis\snot\sstack'd,\smalloc'd\sor\s(recently)\nfree'd\n==18208==\n==18208==\n==18208==\sHEAP\sSUMMARY:\n==18208==\s\s\s\s\sin\suse\sat\sexit:\s14,400\sbytes\sin\s6\sblocks\n==18208==\s\s\stotal\sheap\susage:\s2,190\sallocs,\s2,185\sfrees,\s106,298\sbytes\nallocated\n==18208==\n==18208==\s14,400\s(2,400\sdirect,\s12,000\sindirect)\sbytes\sin\s1\sblocks\sare\ndefinitely\slost\sin\sloss\srecord\s6\sof\s6\n==18208==\s\s\s\sat\s0x4005903:\smalloc\s(vg_replace_malloc.c:195)\n==18208==\s\s\s\sby\s0x402ADAC:\sTclpAlloc\s(in\s/home/militho/dev/src/auxil/\ntcl8.6b1/lib/libtcl8.6.so)\n==18208==\s\s\s\sby\s0x4038094:\sTcl_Alloc\s(in\s/home/militho/dev/src/auxil/\ntcl8.6b1/lib/libtcl8.6.so)\n==18208==\s\s\s\sby\s0x40B93FE:\sTclAllocateFreeObjects\s(in\s/home/militho/\ndev/src/auxil/tcl8.6b1/lib/libtcl8.6.so)\n==18208==\s\s\s\sby\s0x40B9694:\sTcl_NewObj\s(in\s/home/militho/dev/src/auxil/\ntcl8.6b1/lib/libtcl8.6.so)\n==18208==\s\s\s\sby\s0x4032D4E:\sTcl_CreateInterp\s(in\s/home/militho/dev/src/\nauxil/tcl8.6b1/lib/libtcl8.6.so)\n==18208==\s\s\s\sby\s0x8048625:\smain\s(in\s/home/jgilbert/dev/src/tcs/a.out)\n==18208==\n==18208==\sLEAK\sSUMMARY:\n==18208==\s\s\s\sdefinitely\slost:\s2,400\sbytes\sin\s1\sblocks\n==18208==\s\s\s\sindirectly\slost:\s12,000\sbytes\sin\s5\sblocks\n==18208==\s\s\s\s\s\spossibly\slost:\s0\sbytes\sin\s0\sblocks\n==18208==\s\s\s\sstill\sreachable:\s0\sbytes\sin\s0\sblocks\n==18208==\s\s\s\s\s\s\s\s\ssuppressed:\s0\sbytes\sin\s0\sblocks\n==18208==\n==18208==\sFor\scounts\sof\sdetected\sand\ssuppressed\serrors,\srerun\swith:\s-v\n==18208==\sERROR\sSUMMARY:\s2\serrors\sfrom\s2\scontexts\s(suppressed:\s25\sfrom\n10)\n\nSome\sthings\sI've\snoticed:\n\n1.\sWithout\sthe\scall\sto\sTcl_Finalize()\sI\sget\seven\smore\serrors.\n2.\sIf\sI\schange\sexit(0)\sto\sreturn(0)\sthere\sis\sno\schange.\n3.\sSimply\slinking\swith\sthe\sTCL\slibrary\scauses\sthe\sfirst\smessage\sabout\nthe\sinvalid\sfree/delete,\swith\sall\scode\scommented\sout\sexcept\sexit(0).\n\nHas\sanyone\selse\sseen\sthis?\sI'm\swondering\sif\sthis\sis\sa\slegitimate\nmemory\sleak\sin\sTCL\s8.6b1.\sI\ssearched\sbugs\susing\sthe\sstring\s"memory\sleak\sTcl_CreateIterp"\sand\sfound\ssome\ssimilar\sbugs,\sbut\sdidn't\ssee\sany\ssolutions\sthat\sreally\sapplied\sfor\sme.\n\nI\sam\snot\ssure\sthis\smatters,\sbut\sI\sam\susing\sRHEL\skernel\s2.6.18-8.el5\s.\n\nThanks!\s
J foundin obsolete:\s8.6b1
J is_private 0
J priority 5\sMedium
J resolution None
J status Open
J submitter juddgilbert
J subsystem None
J title Valgrind\sreports\sTCL\smemory\sleak\s
J type Bug
K 3290426fffffffffffffffffffffffffffffffff
U juddgilbert
Z 8dd755f4cc6e48d679989ae190256aa5