Menu

#126 quotacheck tool leaks memory when scanning ext file system directly

None
closed-fixed
Jan Kara
None
5
2017-08-31
2017-08-21
No

The ext file system direct scanning in quotacheck suffers from memory leaks:

# dd if=/dev/zero of=disk.img bs=1M count=40
# mkfs.ext4 -F disk.img
# mount -o loop,jqfmt=vfsv1,usrjquota=aquota.user disk.img /mnt/1
# valgrind --leak-check=yes /tmp/linuxquota-git/quotacheck -f /mnt/1/
==8897== Memcheck, a memory error detector
==8897== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==8897== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==8897== Command: /tmp/linuxquota-git/quotacheck -f /mnt/1/
==8897==
==8897==
==8897== HEAP SUMMARY:
==8897==     in use at exit: 25,099 bytes in 30 blocks
==8897==   total heap usage: 188 allocs, 158 frees, 69,764 bytes allocated
==8897==
==8897== 1,392 (88 direct, 1,304 indirect) bytes in 1 blocks are definitely lost in loss record 19 of 23
==8897==    at 0x4C29BE3: malloc (vg_replace_malloc.c:299)
==8897==    by 0x4E5288B: ext2fs_make_generic_bitmap (in /usr/lib64/libext2fs.so.2.4)
==8897==    by 0x4E47ED5: ext2fs_allocate_inode_bitmap (in /usr/lib64/libext2fs.so.2.4)
==8897==    by 0x10BBA5: ext2_direct_scan (quotacheck.c:435)
==8897==    by 0x10DA8A: check_dir (quotacheck.c:971)
==8897==    by 0x10E634: check_all (quotacheck.c:1192)
==8897==    by 0x10E6EC: main (quotacheck.c:1212)
==8897==
==8897== 8,464 (144 direct, 8,320 indirect) bytes in 1 blocks are definitely lost in loss record 22 of 23
==8897==    at 0x4C29BE3: malloc (vg_replace_malloc.c:299)
==8897==    by 0x4E5749D: ext2fs_open_inode_scan (in /usr/lib64/libext2fs.so.2.4)
==8897==    by 0x10BBF0: ext2_direct_scan (quotacheck.c:440)
==8897==    by 0x10DA8A: check_dir (quotacheck.c:971)
==8897==    by 0x10E634: check_all (quotacheck.c:1192)
==8897==    by 0x10E6EC: main (quotacheck.c:1212)
==8897==
==8897== 15,243 (88 direct, 15,155 indirect) bytes in 1 blocks are definitely lost in loss record 23 of 23
==8897==    at 0x4C29BE3: malloc (vg_replace_malloc.c:299)
==8897==    by 0x4E5288B: ext2fs_make_generic_bitmap (in /usr/lib64/libext2fs.so.2.4)
==8897==    by 0x4E47ED5: ext2fs_allocate_inode_bitmap (in /usr/lib64/libext2fs.so.2.4)
==8897==    by 0x10BB55: ext2_direct_scan (quotacheck.c:430)
==8897==    by 0x10DA8A: check_dir (quotacheck.c:971)
==8897==    by 0x10E634: check_all (quotacheck.c:1192)
==8897==    by 0x10E6EC: main (quotacheck.c:1212)
==8897==
==8897== LEAK SUMMARY:
==8897==    definitely lost: 320 bytes in 3 blocks
==8897==    indirectly lost: 24,779 bytes in 27 blocks
==8897==      possibly lost: 0 bytes in 0 blocks
==8897==    still reachable: 0 bytes in 0 blocks
==8897==         suppressed: 0 bytes in 0 blocks
==8897==
==8897== For counts of detected and suppressed errors, rerun with: -v
==8897== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)

The attached patch fixes it.

1 Attachments

Discussion

  • Jan Kara

    Jan Kara - 2017-08-31

    Thanks! I have merged the patch with a slight change to avoid repeated cleanup sequence.

     
  • Jan Kara

    Jan Kara - 2017-08-31
    • status: open --> closed-fixed
    • assigned_to: Jan Kara
    • Group: -->
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB