containers / composefs

a file system for mounting container images
GNU General Public License v2.0
426 stars 29 forks source link

memleaks on error from CLI #343

Open cgwalters opened 6 days ago

cgwalters commented 6 days ago

So today our error paths for executing the CLI in "should fail" cases just check that the binary exits with an error...

But we have memory leaks in some error paths it seems

Indirect leak of 4071 byte(s) in 1 object(s) allocated from:
    #0 0x7f67984f1aa0 in strdup (/lib64/libasan.so.8+0xf1aa0) (BuildId: 79824421bd82bb3ef4addf048e1265e2a93cfc64)
    #1 0x7f6798b73fe0 in lcfs_node_set_payload ../libcomposefs/lcfs-writer.c:920
    #2 0x7f6798b74328 in lcfs_node_set_symlink_payload ../libcomposefs/lcfs-writer.c:943
    #3 0x408609 in tree_from_dump_line ../tools/mkcomposefs.c:550
    #4 0x40998f in tree_from_dump ../tools/mkcomposefs.c:692
    #5 0x410165 in main ../tools/mkcomposefs.c:1696
    #6 0x7f679823d087 in __libc_start_call_main (/lib64/libc.so.6+0x2a087) (BuildId: 4a92fcedbba6d6d2629ce066a2970017faa9995e)
    #7 0x7f679823d14a in __libc_start_main_alias_2 (/lib64/libc.so.6+0x2a14a) (BuildId: 4a92fcedbba6d6d2629ce066a2970017faa9995e)
    #8 0x403744 in _start (/var/home/walters/src/github/containers/composefs/target/tools/mkcomposefs+0x403744) (BuildId: a27689977e2ea2fbdfc0379750b22f16b6276e69)

From 5 seconds of investigation I think this is us just using lcfs_node_unref() and not lcfs_node_destroy() (which isn't public API) in the mkcomposefs.c.

jeckersb commented 5 days ago

I'll take a look at this. I started reading through and digesting the libcomposefs internals yesterday, makes me miss the rust docgen even if just to look at function signatures and type definitions in one easily searchable place :crab: