Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-08-20
20:41
Merge [4ff2b2f9b8eccf37]: Merge 8.7. Bug [d7849f7721]. zipfs memory leak. check-in: 600cfb2a59 user: pooryorick tags: unchained, INCOMPATIBLE_LICENSE
2023-09-16
11:02 • Closed ticket [d7849f7721]: valgrind detected memory leak in latest zipfs pl... artifact: 7051ab387c user: apnadkarni
08:29
Merge 8.7. Bug [d7849f7721]. zipfs memory leak. check-in: 4ff2b2f9b8 user: apnadkarni tags: trunk, main
08:23 • Ticket [d7849f7721] valgrind detected memory leak in latest zipfs status sti... artifact: fd66c56af1 user: apnadkarni
07:48
Bug [d7849f7721]. zipfs memory leak. check-in: 96a4c5ad17 user: apnadkarni tags: core-8-branch
02:45 • Ticket [d7849f7721] valgrind detected memory leak in latest zipfs status sti... artifact: 11febb7ba8 user: apnadkarni
2023-09-15
17:15 • New ticket [d7849f7721]. artifact: 8405871ffa user: dgp

valgrind detected memory leak in latest zipfs

Closed / Fixedd7849f77215ce9a2a0edf5ea78da53d87d48264dCreated 3 years agoUpdated 3 years ago
Descriptionplain2023-09-15 17:15:34
==13348== 4,148 bytes in 10 blocks are definitely lost in loss record 12,350 of 12,586
==13348==    at 0x4C29F73: malloc (vg_replace_malloc.c:309)
==13348==    by 0x60FE28: TclpAlloc (tclAlloc.c:699)
==13348==    by 0x5C3E6A: AllocateZipFile (tclZipfs.c:1076)
==13348==    by 0x5C631E: TclZipfs_MountBuffer (tclZipfs.c:2164)
==13348==    by 0x5C6946: ZipFSMountBufferObjCmd (tclZipfs.c:2391)
==13348==    by 0x43593B: Dispatch (tclBasic.c:4920)
==13348==    by 0x4359C3: TclNRRunCallbacks (tclBasic.c:4960)
==13348==    by 0x43528F: Tcl_EvalObjv (tclBasic.c:4679)
==13348==    by 0x4378FB: TclEvalEx (tclBasic.c:5837)
==13348==    by 0x55B42A: Tcl_FSEvalFileEx (tclIOUtil.c:1782)
==13348==    by 0x5680B2: Tcl_MainEx (tclMain.c:405)
==13348==    by 0x40FF78: main (tclAppInit.c:94)
Referenced by3
apnadkarnimarkdown2023-09-16 02:45:16

Latent bugs, triggered by now actually having tests.

First analysis - ZipChannel.ubuf which is leaked may point to allocated memory (in which case it needs to be freed) or within a mapped zip file (in which case it must not). However, insufficient information is maintained as to whether it needs freeing. Currently, it is only freed when the file was compressed. However, memory is also allocated if file was encrypted without being compressed, or if the file is opened for write. Further complicating matters, in the encrypted case the field is updated to point within the allocation so the pointer to the allocation base is "lost".

Fixing needs some thought.

apnadkarnimarkdown2023-09-16 08:23:45

Fixed for 8.7 in [96a4c5ad17].

==308386== LEAK SUMMARY:
==308386==    definitely lost: 0 bytes in 0 blocks
==308386==    indirectly lost: 0 bytes in 0 blocks
==308386==      possibly lost: 0 bytes in 0 blocks
==308386==    still reachable: 16 bytes in 1 blocks
==308386==         suppressed: 8,809 bytes in 22 blocks
==308386==
==308386== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
--308386--
apnadkarni Closed ticket [d7849f7721]. [History diff]2023-09-16 11:02:28
Log in (anonymous is fine) to add a comment.