Date: Fri, 28 Feb 2025 16:32:58 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 282576] Memory leak in sysctlbyname FreeBSD 14.1-RELEASE-p5 GENERIC x64 Message-ID: <bug-282576-227-LLoWrmLn4y@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-282576-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=282576 Dag-Erling Smørgrav <des@FreeBSD.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |des@FreeBSD.org --- Comment #3 from Dag-Erling Smørgrav <des@FreeBSD.org> --- The “leak” isn't even in sysctlbyname(), which never allocates memory; it's in printf(). You get the exact same result from this program: int main(void) { printf("Hello, world!\n"); } Simply put, by default, the first time you try to print to stdout, libc will allocate a 4 kB buffer which is never freed. Adding the following line at the top of your program renders stdout unbuffered and prevents the “leak”: setbuf(stdout, NULL); Valgrind incorrectly reports the allocation as having occurred in vfprintf_l(). It actually takes place in __smakebuf(). I suspect valgrind gets confused because large parts of stdio are implemented as macros and inline functions for performance reasons. -- You are receiving this mail because: You are the assignee for the bug.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-282576-227-LLoWrmLn4y>
