Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-12-14
05:12 • Ticket [1083082fff] Memory leak at startup status still Closed with 7 other ... artifact: e8e31b4981 user: dgp
05:11 • Closed ticket [1083082fff]. artifact: 9255ecb18a user: dgp
04:23 • Ticket [1083082fff]: 4 changes artifact: 26a5e3540e user: pointsman
02:15 • Ticket [1083082fff]: 4 changes artifact: 04d4ccda1f user: dgp
02:15 • Add attachment 1083082.patch to ticket [1083082fff] artifact: 86f8053e6e user: dgp
2004-12-11
09:36 • Ticket [1083082fff] Memory leak at startup status still Open with 4 other ch... artifact: 5a3ff21b55 user: pointsman
05:18 • Ticket [1083082fff]: 7 changes artifact: 4e1aff8d13 user: dgp
02:57 • Ticket [1083082fff]: 4 changes artifact: 5310b58924 user: dgp
02:35 • Ticket [1083082fff]: 4 changes artifact: 4fcb8fd59e user: pointsman
02:22 • Ticket [1083082fff]: 4 changes artifact: 07c43f6596 user: dgp
02:17 • Ticket [1083082fff]: 4 changes artifact: ac45253f3b user: dgp
2004-12-10
18:15 • New ticket [1083082fff]. artifact: e22b59db39 user: pointsman

Memory leak at startup

Closed / Fixed1083082fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2004-12-10 18:15:48
tcl head 10 dec 2004, compiled with --enable-symbols,
-DPURIFY.

Script is only:

proc exit args {}

valgrind reports:

==18300== ERROR SUMMARY: 0 errors from 0 contexts
(suppressed: 27 from 2)
==18300== malloc/free: in use at exit: 12742 bytes in
264 blocks.
==18300== malloc/free: 6005 allocs, 5741 frees, 394569
bytes allocated.
==18300== For counts of detected errors, rerun with: -v
==18300== searching for pointers to 264 not-freed blocks.
==18300== checked 4668828 bytes.
==18300== 
==18300== 120 bytes in 5 blocks are definitely lost in
loss record 2 of 3
==18300==    at 0x40027B98: malloc
(vg_replace_malloc.c:153)
==18300==    by 0x40251A1D: TclpAlloc
(../generic/tclAlloc.c:685)
==18300==    by 0x402592E5: Tcl_Alloc
(../generic/tclCkalloc.c:1018)
==18300==    by 0x402DBD38: Tcl_NewStringObj
(../generic/tclStringObj.c:211)
==18300==    by 0x402E6C9E: TclGetProcessGlobalValue
(../generic/tclUtil.c:2798)
==18300==    by 0x4028801B: TclGetLibraryPath
(../generic/tclEncoding.c:325)
==18300==    by 0x4028B242:
InitializeEncodingSearchPath (../generic/tclEncoding
.c:3074)
==18300==    by 0x402E6C72: TclGetProcessGlobalValue
(../generic/tclUtil.c:2790)
==18300==    by 0x40287F91: TclGetEncodingSearchPath
(../generic/tclEncoding.c:2
81)
==18300==    by 0x4028808C: MakeFileMap
(../generic/tclEncoding.c:385)
==18300==    by 0x4028B3B8: InitializeEncodingFileMap
(../generic/tclEncoding.c:
3129)
==18300==    by 0x402E6C72: TclGetProcessGlobalValue
(../generic/tclUtil.c:2790)
==18300==    by 0x40288E8F: LoadEncodingFile
(../generic/tclEncoding.c:1344)
==18300==    by 0x4028857B: Tcl_GetEncoding
(../generic/tclEncoding.c:669)
==18300==    by 0x402F4811:
TclpGetEncodingNameFromEnvironment (tclUnixInit.c:61
5)
==18300==    by 0x402F4752: TclpSetInitialEncodings
(tclUnixInit.c:581)
==18300==    by 0x40288E31: Tcl_FindExecutable
(../generic/tclEncoding.c:1305)
==18300==    by 0x402BBC12: Tcl_Main
(../generic/tclMain.c:339)
==18300==    by 0x8048705: main (tclAppInit.c:87)
==18300==    by 0x4035D8AD: __libc_start_main (in
/lib/libc.so.6)
==18300== 
==18300== LEAK SUMMARY:
==18300==    definitely lost: 120 bytes in 5 blocks.
==18300==    possibly lost:   0 bytes in 0 blocks.
==18300==    still reachable: 12622 bytes in 259 blocks.
==18300==         suppressed: 0 bytes in 0 blocks.
==18300== Reachable blocks (those to which a pointer
was found) are not shown.
==18300== To see them, rerun with: --show-reachable=yes
==18300==
dgpplain2004-12-11 02:17:38
Logged In: YES 
user_id=80530


Thanks for the report.

Looks like FreeThreadHash
is missing a ClearHash call...
dgpplain2004-12-11 02:22:37
File Added - 112015: 1083082.patch

Logged In: YES 
user_id=80530

please test this patch.
pointsmanplain2004-12-11 02:35:53
Logged In: YES 
user_id=13222

Tested with the patch. Looks like sill not clean. 

Now valgrind reports:

==22390== ERROR SUMMARY: 0 errors from 0 contexts
(suppressed: 27 from 2)
==22390== malloc/free: in use at exit: 272 bytes in 10 blocks.
==22390== malloc/free: 5979 allocs, 5969 frees, 393962 bytes
allocated.
==22390== For counts of detected errors, rerun with: -v
==22390== searching for pointers to 10 not-freed blocks.
==22390== checked 4661072 bytes.
==22390== 
==22390== 48 bytes in 2 blocks are definitely lost in loss
record 1 of 3
==22390==    at 0x40027B98: malloc (vg_replace_malloc.c:153)
==22390==    by 0x40251A1D: TclpAlloc
(../generic/tclAlloc.c:685)
==22390==    by 0x402592E5: Tcl_Alloc
(../generic/tclCkalloc.c:1018)
==22390==    by 0x402DBD38: Tcl_NewStringObj
(../generic/tclStringObj.c:211)
==22390==    by 0x40288E6E: LoadEncodingFile
(../generic/tclEncoding.c:1338)
==22390==    by 0x4028857B: Tcl_GetEncoding
(../generic/tclEncoding.c:669)
==22390==    by 0x4028884B: Tcl_SetSystemEncoding
(../generic/tclEncoding.c:870)
==22390==    by 0x402F476D: TclpSetInitialEncodings
(tclUnixInit.c:581)
==22390==    by 0x40288E31: Tcl_FindExecutable
(../generic/tclEncoding.c:1305)
==22390==    by 0x402BBC12: Tcl_Main (../generic/tclMain.c:339)
==22390==    by 0x8048705: main (tclAppInit.c:87)
==22390==    by 0x4035D8AD: __libc_start_main (in
/lib/libc.so.6)
==22390==    by 0x8048630: (within
/usr/local/tcl-head/bin/tclsh8.5)
==22390== 
==22390== LEAK SUMMARY:
==22390==    definitely lost: 48 bytes in 2 blocks.
==22390==    possibly lost:   0 bytes in 0 blocks.
==22390==    still reachable: 224 bytes in 8 blocks.
==22390==         suppressed: 0 bytes in 0 blocks.
dgpplain2004-12-11 02:57:27
File Deleted - 112015: 



File Added - 112020: 1083082.patch

Logged In: YES 
user_id=80530

updated patch should correct that too.
dgpplain2004-12-11 05:18:41
Logged In: YES 
user_id=80530

please test and report when you
get a chance.
pointsmanplain2004-12-11 09:36:15
Logged In: YES 
user_id=13222

Fixed now. Valgrind doesn't report any 'definitely lost'
memory any more. With the 'exit trick' from 
http://mini.net/tcl/3248, even the 'still reachable' are
almost back to the low numbers of the late 8.4.x releases.
I'm aware, that they are another topic and no real harm, but
only noise. They are currently:

==27065== ERROR SUMMARY: 0 errors from 0 contexts
(suppressed: 27 from 2)
==27065== malloc/free: in use at exit: 132 bytes in 4 blocks.
==27065== malloc/free: 5979 allocs, 5975 frees, 393983 bytes
allocated.
==27065== For counts of detected errors, rerun with: -v
==27065== searching for pointers to 4 not-freed blocks.
==27065== checked 4660992 bytes.
==27065== 
==27065== 40 bytes in 1 blocks are still reachable in loss
record 1 of 2
==27065==    at 0x4002811A: realloc (vg_replace_malloc.c:310)
==27065==    by 0x40251A6C: TclpRealloc
(../generic/tclAlloc.c:733)
==27065==    by 0x402593F0: Tcl_Realloc
(../generic/tclCkalloc.c:1101)
==27065==    by 0x402DC514: Tcl_SetObjLength
(../generic/tclStringObj.c:777)
==27065==    by 0x4029C869: TclpNativeJoinPath
(../generic/tclFileName.c:764)
==27065==    by 0x402CE485: Tcl_FSJoinPath
(../generic/tclPathObj.c:993)
==27065==    by 0x4029C764: Tcl_FSJoinToPath
(../generic/tclFileName.c:689)
==27065==    by 0x4028B3CC: InitializeEncodingSearchPath
(../generic/tclEncoding.c:3083)
==27065==    by 0x402E6E04: TclGetProcessGlobalValue
(../generic/tclUtil.c:2791)
==27065==    by 0x402880B1: TclGetEncodingSearchPath
(../generic/tclEncoding.c:281)
==27065==    by 0x402881AC: MakeFileMap
(../generic/tclEncoding.c:385)
==27065==    by 0x4028B4F0: InitializeEncodingFileMap
(../generic/tclEncoding.c:3130)
==27065==    by 0x402E6E04: TclGetProcessGlobalValue
(../generic/tclUtil.c:2791)
==27065==    by 0x40288FAF: LoadEncodingFile
(../generic/tclEncoding.c:1344)
==27065==    by 0x4028869B: Tcl_GetEncoding
(../generic/tclEncoding.c:669)
==27065==    by 0x402F49A5:
TclpGetEncodingNameFromEnvironment (tclUnixInit.c:615)
==27065==    by 0x402F48E6: TclpSetInitialEncodings
(tclUnixInit.c:581)
==27065==    by 0x40288F51: Tcl_FindExecutable
(../generic/tclEncoding.c:1305)
==27065==    by 0x402BBD4A: Tcl_Main (../generic/tclMain.c:339)
==27065==    by 0x8048705: main (tclAppInit.c:87)
==27065== 
==27065== 
==27065== 92 bytes in 3 blocks are still reachable in loss
record 2 of 2
==27065==    at 0x40027B98: malloc (vg_replace_malloc.c:153)
==27065==    by 0x40251A1D: TclpAlloc
(../generic/tclAlloc.c:685)
==27065==    by 0x402592E5: Tcl_Alloc
(../generic/tclCkalloc.c:1018)
==27065==    by 0x402DBEBC: Tcl_NewStringObj
(../generic/tclStringObj.c:211)
==27065==    by 0x402CE218: Tcl_FSJoinPath
(../generic/tclPathObj.c:910)
==27065==    by 0x4029C764: Tcl_FSJoinToPath
(../generic/tclFileName.c:689)
==27065==    by 0x4028B3CC: InitializeEncodingSearchPath
(../generic/tclEncoding.c:3083)
==27065==    by 0x402E6E04: TclGetProcessGlobalValue
(../generic/tclUtil.c:2791)
==27065==    by 0x402880B1: TclGetEncodingSearchPath
(../generic/tclEncoding.c:281)
==27065==    by 0x402881AC: MakeFileMap
(../generic/tclEncoding.c:385)
==27065==    by 0x4028B4F0: InitializeEncodingFileMap
(../generic/tclEncoding.c:3130)
==27065==    by 0x402E6E04: TclGetProcessGlobalValue
(../generic/tclUtil.c:2791)
==27065==    by 0x40288FAF: LoadEncodingFile
(../generic/tclEncoding.c:1344)
==27065==    by 0x4028869B: Tcl_GetEncoding
(../generic/tclEncoding.c:669)
==27065==    by 0x402F49A5:
TclpGetEncodingNameFromEnvironment (tclUnixInit.c:615)
==27065==    by 0x402F48E6: TclpSetInitialEncodings
(tclUnixInit.c:581)
==27065==    by 0x40288F51: Tcl_FindExecutable
(../generic/tclEncoding.c:1305)
==27065==    by 0x402BBD4A: Tcl_Main (../generic/tclMain.c:339)
==27065==    by 0x8048705: main (tclAppInit.c:87)
==27065==    by 0x4035D8AD: __libc_start_main (in
/lib/libc.so.6)
==27065== 
==27065== LEAK SUMMARY:
==27065==    definitely lost: 0 bytes in 0 blocks.
==27065==    possibly lost:   0 bytes in 0 blocks.
==27065==    still reachable: 132 bytes in 4 blocks.
==27065==         suppressed: 0 bytes in 0 blocks.
==27065==
dgpplain2004-12-14 02:15:21
File Deleted - 112020: 



File Added - 112328: 1083082.patch

Logged In: YES 
user_id=80530


another patch update.  please test again.
pointsmanplain2004-12-14 04:23:55
Logged In: YES 
user_id=13222

Hey! Now, at least for the given very simple test script
with only the exit trick from above, tcl cleans up *all*
memory after itself.

That's what valgrind say:

 ==24057== ERROR SUMMARY: 0 errors from 0 contexts
(suppressed: 26 from 2)
==24057== malloc/free: in use at exit: 0 bytes in 0 blocks.
==24057== malloc/free: 5954 allocs, 5954 frees, 393712 bytes
allocated.
==24057== For counts of detected errors, rerun with: -v
==24057== No malloc'd blocks -- no leaks are possible.

Great!
dgp Closed ticket [1083082fff]. [History diff]2004-12-14 05:11:59
dgpplain2004-12-14 05:12:00
Logged In: YES 
user_id=80530

fixed in HEAD for 8.5a3
Log in (anonymous is fine) to add a comment.

Attachments: