You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using valgrind 3.18.1-1 on x86_64 r18400-f9782f5bcd. This build uses musl 1.2.2-3. My libraries, to include libc, are not stripped.
According to the upstream bug at https://bugs.kde.org/show_bug.cgi?id=435441, changes to musl left valgrind unable to detect memory leaks. The workaround proposed in that bug report, namely passing "--soname-synonyms=somalloc=NONE" to valgrind, seems to fix the problem on OpenWrt.
Here is an example program:
#include
#include
int f(void) {
char *buf = malloc(BUFSIZ);
if (buf == NULL) {
return -1;
}
return 0;
}
int main(void)
{
f();
}
I compiled this with "gcc -O0 -o test test.c", and I ran the following to demonstrate the problem and workaround:
$ valgrind --leak-check=full ./test
==31728== Memcheck, a memory error detector
==31728== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==31728== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==31728== Command: ./test
==31728==
==31728==
==31728== HEAP SUMMARY:
==31728== in use at exit: 0 bytes in 0 blocks
==31728== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==31728==
==31728== All heap blocks were freed -- no leaks are possible
==31728==
==31728== For lists of detected and suppressed errors, rerun with: -s
==31728== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
$ valgrind --leak-check=full --soname-synonyms=somalloc=NONE ./test
==31732== Memcheck, a memory error detector
==31732== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==31732== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==31732== Command: ./test
==31732==
==31732==
==31732== HEAP SUMMARY:
==31732== in use at exit: 1,024 bytes in 1 blocks
==31732== total heap usage: 1 allocs, 0 frees, 1,024 bytes allocated
==31732==
==31732== 1,024 bytes in 1 blocks are definitely lost in loss record 1 of 1
==31732== at 0x48806B6: malloc (vg_replace_malloc.c:381)
==31732== by 0x40111B: f (in /home/mike@flyn.org/valgrindC/test)
==31732== by 0x40113D: main (in /home/mike@flyn.org/valgrindC/test)
==31732==
==31732== LEAK SUMMARY:
==31732== definitely lost: 1,024 bytes in 1 blocks
==31732== indirectly lost: 0 bytes in 0 blocks
==31732== possibly lost: 0 bytes in 0 blocks
==31732== still reachable: 0 bytes in 0 blocks
==31732== suppressed: 0 bytes in 0 blocks
==31732==
==31732== For lists of detected and suppressed errors, rerun with: -s
==31732== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
The text was updated successfully, but these errors were encountered:
MikePetullo:
I am using valgrind 3.18.1-1 on x86_64 r18400-f9782f5bcd. This build uses musl 1.2.2-3. My libraries, to include libc, are not stripped.
According to the upstream bug at https://bugs.kde.org/show_bug.cgi?id=435441, changes to musl left valgrind unable to detect memory leaks. The workaround proposed in that bug report, namely passing "--soname-synonyms=somalloc=NONE" to valgrind, seems to fix the problem on OpenWrt.
Here is an example program:
#include #include
int f(void) {
char *buf = malloc(BUFSIZ);
if (buf == NULL) {
return -1;
}
return 0;
}
int main(void)
{
f();
}
I compiled this with "gcc -O0 -o test test.c", and I ran the following to demonstrate the problem and workaround:
$ valgrind --leak-check=full ./test
==31728== Memcheck, a memory error detector
==31728== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==31728== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==31728== Command: ./test
==31728==
==31728==
==31728== HEAP SUMMARY:
==31728== in use at exit: 0 bytes in 0 blocks
==31728== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==31728==
==31728== All heap blocks were freed -- no leaks are possible
==31728==
==31728== For lists of detected and suppressed errors, rerun with: -s
==31728== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
$ valgrind --leak-check=full --soname-synonyms=somalloc=NONE ./test
==31732== Memcheck, a memory error detector
==31732== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==31732== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==31732== Command: ./test
==31732==
==31732==
==31732== HEAP SUMMARY:
==31732== in use at exit: 1,024 bytes in 1 blocks
==31732== total heap usage: 1 allocs, 0 frees, 1,024 bytes allocated
==31732==
==31732== 1,024 bytes in 1 blocks are definitely lost in loss record 1 of 1
==31732== at 0x48806B6: malloc (vg_replace_malloc.c:381)
==31732== by 0x40111B: f (in /home/mike@flyn.org/valgrindC/test)
==31732== by 0x40113D: main (in /home/mike@flyn.org/valgrindC/test)
==31732==
==31732== LEAK SUMMARY:
==31732== definitely lost: 1,024 bytes in 1 blocks
==31732== indirectly lost: 0 bytes in 0 blocks
==31732== possibly lost: 0 bytes in 0 blocks
==31732== still reachable: 0 bytes in 0 blocks
==31732== suppressed: 0 bytes in 0 blocks
==31732==
==31732== For lists of detected and suppressed errors, rerun with: -s
==31732== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
The text was updated successfully, but these errors were encountered: