Bug 408663 - Patch: Suppression file for musl libc
Summary: Patch: Suppression file for musl libc
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.14.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-13 20:18 UTC by karltheodor
Modified: 2020-12-08 14:10 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch adding a suppression file for musl (1.37 KB, patch)
2019-06-13 20:18 UTC, karltheodor
Details
Update suppression file (695 bytes, text/plain)
2020-11-27 17:24 UTC, Paul Floyd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description karltheodor 2019-06-13 20:18:53 UTC
Created attachment 120849 [details]
Patch adding a suppression file for musl

SUMMARY

Valgrind doesn't have a default suppression file for musl and therefore reports false-positive memory leaks for dynlink
(See https://www.openwall.com/lists/musl/2017/06/15/4). This bug report contains a patch adding such a suppression file.

STEPS TO REPRODUCE

Consider the following C program:


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int
main(void)
{
	char *str;

	str = strdup("foo");
	printf("%s\n", str);
	free(str);
	return 0;
}

Compile and link this program against musl libc and invoke it using valgrind.

OBSERVED RESULT

$ cc -o test test.c
$ valgrind --leak-check=full --show-leak-kinds=all ./test
==29077== HEAP SUMMARY:
==29077==     in use at exit: 476 bytes in 4 blocks
==29077==   total heap usage: 6 allocs, 2 frees, 520 bytes allocated
==29077== 
==29077== 48 bytes in 3 blocks are still reachable in loss record 1 of 2
==29077==    at 0x489D6F0: calloc (vg_replace_malloc.c:752)
==29077==    by 0x40587F2: load_direct_deps (dynlink.c:1170)
==29077==    by 0x40587F2: load_deps (dynlink.c:1197)
==29077==    by 0x40587F2: load_deps (dynlink.c:1193)
==29077==    by 0x40591BF: __dls3 (dynlink.c:1832)
==29077==    by 0x4058BA6: __dls2b (dynlink.c:1660)
==29077==    by 0x4058B4B: __dls2 (dynlink.c:1638)
==29077==    by 0x405674F: ??? (in /lib/ld-musl-x86_64.so.1)
==29077== 
==29077== 428 bytes in 1 blocks are still reachable in loss record 2 of 2
==29077==    at 0x489D6F0: calloc (vg_replace_malloc.c:752)
==29077==    by 0x40585BA: load_library (dynlink.c:1110)
==29077==    by 0x40591FD: load_preload (dynlink.c:1260)
==29077==    by 0x40591FD: __dls3 (dynlink.c:1831)
==29077==    by 0x4058BA6: __dls2b (dynlink.c:1660)
==29077==    by 0x4058B4B: __dls2 (dynlink.c:1638)
==29077==    by 0x405674F: ??? (in /lib/ld-musl-x86_64.so.1)
==29077== 
==29077== LEAK SUMMARY:
==29077==    definitely lost: 0 bytes in 0 blocks
==29077==    indirectly lost: 0 bytes in 0 blocks
==29077==      possibly lost: 0 bytes in 0 blocks
==29077==    still reachable: 476 bytes in 4 blocks
==29077==         suppressed: 0 bytes in 0 blocks
==29077== 
==29077== For counts of detected and suppressed errors, rerun with: -v
==29077== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

EXPECTED RESULT

Valgrind shouldn't report any errors.

SOFTWARE/OS VERSIONS

Alpine Linux Edge, Valgrind 3.14

ADDITIONAL INFORMATION

This was copied from Alpine Linux: https://github.com/alpinelinux/aports/pull/8779
Comment 1 Paul Floyd 2020-11-25 20:02:09 UTC
I was recently doing some build testing on Alpine Linux, so I'll add this one to my todo list. It should be very straightforward.
Comment 2 Paul Floyd 2020-11-27 17:24:34 UTC
Created attachment 133688 [details]
Update suppression file

File taken from the Alpine package build
Comment 3 Mark Wielaard 2020-12-08 11:31:13 UTC
If this has been tested on a distro that actually uses musl as default libc, this seems fine.