Skip to content
Tcl Source Code Artifact [1bea51dfb7]
Login

Artifact [1bea51dfb7]

Artifact 1bea51dfb7812a93ad65fbff662770051dc4a5ad18070bc61e1d02868115e963:

Ticket change [1bea51dfb7] - Closed ticket [3290426fffffffff|3290426fff]: <i>Valgrind reports TCL memory leak</i> plus 9 other changes by chrstphrchvz on 2023-03-26 11:33:47.
D 2023-03-26T11:33:47.582
J closedate 2460029.98180072
J closer chrstphrchvz
J comment Hello,\r\n\r\nI\sam\sseeing\sa\smemory\sleak\susing\sValgrind\swith\sC++\sand\sTCL\s8.6.b1.\sHere\r\nis\smy\sexample\scode:\r\n\r\n#include\s<stdio.h>\r\n#include\s<stdlib.h>\r\n#include\s"tcl.h"\r\n\r\nint\smain(int\sargc,\schar*\sargv[])\r\n{\r\n\s\sTcl_Interp*\sMainInterp;\r\n\s\sprintf("creating\sinterp...\\n");\r\n\s\sMainInterp\s=\sTcl_CreateInterp();\r\n\s\sprintf("deleting\sinterp...\\n");\r\n\s\sTcl_DeleteInterp(MainInterp);\r\n\s\sprintf("finalizing...\\n");\r\n\s\sTcl_Finalize();\r\n\s\sprintf("exiting...\\n");\r\n\s\sexit(0);\r\n\r\n}\r\n\r\nTo\scompile\sI\sam\sdoing\sthe\sfollowing:\r\n\r\n\s../auxil/gcc-4.3.3/bin/g++\s-I../auxil/tcl8.6b1/include\ssrc/\r\ntcltest.cpp\s-ltcl8.6\s-L../auxil/tcl8.6b1/lib\r\n\r\nWhen\srunning\sthe\soutput\sof\sthis\sprogram\susing\sthe\sValgrind\smem\r\nchecker\s:\r\n\r\nvalgrind\s--leak-check=full\s./a.out\r\n\r\nI\sget\sthe\sfollowing\soutput:\r\n\r\n==18208==\sMemcheck,\sa\smemory\serror\sdetector\r\n==18208==\sCopyright\s(C)\s2002-2009,\sand\sGNU\sGPL'd,\sby\sJulian\sSeward\set\r\nal.\r\n==18208==\sUsing\sValgrind-3.5.0\sand\sLibVEX;\srerun\swith\s-h\sfor\scopyright\r\ninfo\r\n==18208==\sCommand:\s./a.out\r\n==18208==\r\ncreating\sinterp...\r\ndeleting\sinterp...\r\nfinalizing...\r\nexiting...\r\n==18208==\sInvalid\sfree()\s/\sdelete\s/\sdelete[]\r\n==18208==\s\s\s\sat\s0x400551D:\sfree\s(vg_replace_malloc.c:325)\r\n==18208==\s\s\s\sby\s0x475C7D2D:\s???\s(in\s/lib/libc-2.5.so)\r\n==18208==\s\s\s\sby\s0x475C78A6:\s???\s(in\s/lib/libc-2.5.so)\r\n==18208==\s\s\s\sby\s0x40013B2:\s_vgnU_freeres\s(vg_preloaded.c:62)\r\n==18208==\s\s\s\sby\s0x475485A3:\s_Exit\s(in\s/lib/libc-2.5.so)\r\n==18208==\s\s\s\sby\s0x8048668:\smain\s(in\s/home/jgilbert/dev/src/tcs/a.out)\r\n==18208==\s\sAddress\s0x4135b18\sis\snot\sstack'd,\smalloc'd\sor\s(recently)\r\nfree'd\r\n==18208==\r\n==18208==\r\n==18208==\sHEAP\sSUMMARY:\r\n==18208==\s\s\s\s\sin\suse\sat\sexit:\s14,400\sbytes\sin\s6\sblocks\r\n==18208==\s\s\stotal\sheap\susage:\s2,190\sallocs,\s2,185\sfrees,\s106,298\sbytes\r\nallocated\r\n==18208==\r\n==18208==\s14,400\s(2,400\sdirect,\s12,000\sindirect)\sbytes\sin\s1\sblocks\sare\r\ndefinitely\slost\sin\sloss\srecord\s6\sof\s6\r\n==18208==\s\s\s\sat\s0x4005903:\smalloc\s(vg_replace_malloc.c:195)\r\n==18208==\s\s\s\sby\s0x402ADAC:\sTclpAlloc\s(in\s/home/militho/dev/src/auxil/\r\ntcl8.6b1/lib/libtcl8.6.so)\r\n==18208==\s\s\s\sby\s0x4038094:\sTcl_Alloc\s(in\s/home/militho/dev/src/auxil/\r\ntcl8.6b1/lib/libtcl8.6.so)\r\n==18208==\s\s\s\sby\s0x40B93FE:\sTclAllocateFreeObjects\s(in\s/home/militho/\r\ndev/src/auxil/tcl8.6b1/lib/libtcl8.6.so)\r\n==18208==\s\s\s\sby\s0x40B9694:\sTcl_NewObj\s(in\s/home/militho/dev/src/auxil/\r\ntcl8.6b1/lib/libtcl8.6.so)\r\n==18208==\s\s\s\sby\s0x4032D4E:\sTcl_CreateInterp\s(in\s/home/militho/dev/src/\r\nauxil/tcl8.6b1/lib/libtcl8.6.so)\r\n==18208==\s\s\s\sby\s0x8048625:\smain\s(in\s/home/jgilbert/dev/src/tcs/a.out)\r\n==18208==\r\n==18208==\sLEAK\sSUMMARY:\r\n==18208==\s\s\s\sdefinitely\slost:\s2,400\sbytes\sin\s1\sblocks\r\n==18208==\s\s\s\sindirectly\slost:\s12,000\sbytes\sin\s5\sblocks\r\n==18208==\s\s\s\s\s\spossibly\slost:\s0\sbytes\sin\s0\sblocks\r\n==18208==\s\s\s\sstill\sreachable:\s0\sbytes\sin\s0\sblocks\r\n==18208==\s\s\s\s\s\s\s\s\ssuppressed:\s0\sbytes\sin\s0\sblocks\r\n==18208==\r\n==18208==\sFor\scounts\sof\sdetected\sand\ssuppressed\serrors,\srerun\swith:\s-v\r\n==18208==\sERROR\sSUMMARY:\s2\serrors\sfrom\s2\scontexts\s(suppressed:\s25\sfrom\r\n10)\r\n\r\nSome\sthings\sI've\snoticed:\r\n\r\n1.\sWithout\sthe\scall\sto\sTcl_Finalize()\sI\sget\seven\smore\serrors.\r\n2.\sIf\sI\schange\sexit(0)\sto\sreturn(0)\sthere\sis\sno\schange.\r\n3.\sSimply\slinking\swith\sthe\sTCL\slibrary\scauses\sthe\sfirst\smessage\sabout\r\nthe\sinvalid\sfree/delete,\swith\sall\scode\scommented\sout\sexcept\sexit(0).\r\n\r\nHas\sanyone\selse\sseen\sthis?\sI'm\swondering\sif\sthis\sis\sa\slegitimate\r\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.\r\n\r\nI\sam\snot\ssure\sthis\smatters,\sbut\sI\sam\susing\sRHEL\skernel\s2.6.18-8.el5\s.\r\n\r\nThanks!
J icomment Duplicate\sof\s[2919042]
J login chrstphrchvz
J mimetype text/x-fossil-wiki
J resolution Duplicate
J severity Minor
J status Closed
J title Valgrind\sreports\sTCL\smemory\sleak
K 3290426fffffffffffffffffffffffffffffffff
U chrstphrchvz
Z 51f0560b1db66cc4958d83644115fc99