On Tue, 11 Nov 2014, Sami Kerola wrote:
I'm running out of ideas.
That was a bit hasty comment. Without '-fsanitize=address' compiler option, while keepign '-O0 -g -ggdb' valgrind was able to display another leak. When both leaks were fixed the mkswap started to return zero expected way.
The second leak was caused by size_to_human_string() that is coming from libcommon.la. Did the ASAN + clang fall over because of libtool static library and atexit()? I don't know, and I guess this maillist is wrong forum to investigate. I'm just happy if someone who has similar issue finds this thread useful.
--->8---- From: Sami Kerola <kerolasa@xxxxxx> Date: Tue, 11 Nov 2014 21:34:30 +0000 Subject: [PATCH v2] mkswap: remove memory leaks [LeakSanitizer] [valgrind] ==18922==ERROR: LeakSanitizer: detected memory leaks Direct leak of 8 byte(s) in 1 object(s) allocated from: #0 0x49d12b in __interceptor_malloc (/home/src/util-linux/.libs/lt-mkswap+0x49d12b) #1 0x7faf2a5069c9 in __GI___strdup (/usr/lib/libc.so.6+0x819c9) #2 0xffff96e7e33 (<unknown module>) SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s). And another one that valgrind found. ==6316== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==6316== at 0x4C29F90: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==6316== by 0x5E3F9C9: strdup (in /usr/lib/libc-2.20.so) ==6316== by 0x43A25F: size_to_human_string (strutils.c:495) ==6316== by 0x42B35C: main (mkswap.c:488) Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- disk-utils/mkswap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index c4fe8c9..d34e2fd 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -323,6 +323,7 @@ static void wipe_device(struct mkswap_control *ctl) fprintf(stderr, _(" (compiled without libblkid). ")); fprintf(stderr, _("Use -f to force.\n")); } + free(type); #ifdef HAVE_LIBBLKID blkid_free_probe(pr); #endif @@ -488,6 +489,7 @@ int main(int argc, char **argv) printf(_("Setting up swapspace version %d, size = %s (%ju bytes)\n"), version, strsz, sz); + free(strsz); set_signature(&ctl); set_uuid_and_label(&ctl); -- 2.1.3 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html