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
600cfb2a59Merge [4ff2b2f9b8eccf37]: Merge 8.7. Bug [d7849f7721]. zipfs memory leak. check-in2024-08-20 20:41:504ff2b2f9b8Merge 8.7. Bug [d7849f7721]. zipfs memory leak. check-in2023-09-16 08:29:5696a4c5ad17Bug [d7849f7721]. zipfs memory leak. check-in2023-09-16 07:48:11
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.