Date: Sun, 04 Feb 2024 09:53:53 +0000 From: bugzilla-noreply@freebsd.org To: threads@FreeBSD.org Subject: [Bug 276818] [libc] mtx_init memory leak Message-ID: <bug-276818-13406-GZjbCvQrBv@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-276818-13406@https.bugs.freebsd.org/bugzilla/> References: <bug-276818-13406@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276818 Hodong <hodong@nimfsoft.art> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|mtx |[libc] mtx_init memory leak --- Comment #1 from Hodong <hodong@nimfsoft.art> --- Hello. A memory leak occurs in mtx_init. #include <threads.h> int main () { mtx_t mtx; mtx_init (&mtx, mtx_plain); mtx_destroy (&mtx); return 0; } $ cc mtx.c -lstdthreads -o mtx $ valgrind --leak-check=3Dfull ./mtx =3D=3D26748=3D=3D Memcheck, a memory error detector =3D=3D26748=3D=3D Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward = et al. =3D=3D26748=3D=3D Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyr= ight info =3D=3D26748=3D=3D Command: ./mtx =3D=3D26748=3D=3D=20 =3D=3D26748=3D=3D=20 =3D=3D26748=3D=3D HEAP SUMMARY: =3D=3D26748=3D=3D in use at exit: 1,748 bytes in 3 blocks =3D=3D26748=3D=3D total heap usage: 3 allocs, 0 frees, 1,748 bytes alloca= ted =3D=3D26748=3D=3D=20 =3D=3D26748=3D=3D 20 bytes in 1 blocks are definitely lost in loss record 1= of 3 =3D=3D26748=3D=3D at 0x484CDE4: malloc (vg_replace_malloc.c:446) =3D=3D26748=3D=3D by 0x4C791B2: pthread_mutexattr_init (in /lib/libthr.s= o.3) =3D=3D26748=3D=3D by 0x485EA9D: mtx_init (in /usr/lib/libstdthreads.so.0) =3D=3D26748=3D=3D by 0x2016FC: main (in /home/hodong/projects/snippets/m= tx) =3D=3D26748=3D=3D=20 =3D=3D26748=3D=3D LEAK SUMMARY: =3D=3D26748=3D=3D definitely lost: 20 bytes in 1 blocks =3D=3D26748=3D=3D indirectly lost: 0 bytes in 0 blocks =3D=3D26748=3D=3D possibly lost: 0 bytes in 0 blocks =3D=3D26748=3D=3D still reachable: 1,728 bytes in 2 blocks =3D=3D26748=3D=3D suppressed: 0 bytes in 0 blocks =3D=3D26748=3D=3D Reachable blocks (those to which a pointer was found) are= not shown. =3D=3D26748=3D=3D To see them, rerun with: --leak-check=3Dfull --show-leak-= kinds=3Dall =3D=3D26748=3D=3D=20 =3D=3D26748=3D=3D For lists of detected and suppressed errors, rerun with: = -s =3D=3D26748=3D=3D ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 fr= om 0) --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-276818-13406-GZjbCvQrBv>