[Bug 259294] [libc] add a freeres function

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 22 Oct 2021 06:07:23 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259294

--- Comment #1 from Paul Floyd <pjfloyd@wanadoo.fr> ---
I'll see if I can work out a patch.

In the meantime, here is the canonical C example

#include <stdio.h>

int main(void)
{
   printf("Hellw, World!\n");
}

If I run

 valgrind --default-suppressions=no --leak-check=full --show-reachable=yes
./hello_world

then I get


==1497== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 1
==1497==    at 0x484C8A4: malloc (in
/usr/local/libexec/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==1497==    by 0x4974AA3: ??? (in /lib/libc.so.7)
==1497==    by 0x4987278: ??? (in /lib/libc.so.7)
==1497==    by 0x497B012: ??? (in /lib/libc.so.7)
==1497==    by 0x497AD89: vfprintf_l (in /lib/libc.so.7)
==1497==    by 0x4975AF3: printf (in /lib/libc.so.7)
==1497==    by 0x2018A8: main (hello_world.c:5)

And for C++ the canonical hello world

#include <iostream>

int main()
{
   std::cout << "Hello, World!\n";
}


valgrind --default-suppressions=no --leak-check=full --show-reachable=yes
./hello_world2

==1507== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 1
==1507==    at 0x484C8A4: malloc (in
/usr/local/libexec/valgrind/vgpreload_memcheck-amd64-freebsd.so)
==1507==    by 0x4AB5AA3: ??? (in /lib/libc.so.7)
==1507==    by 0x4AC8278: ??? (in /lib/libc.so.7)
==1507==    by 0x4AB47D2: ??? (in /lib/libc.so.7)
==1507==    by 0x4AB50A3: fwrite (in /lib/libc.so.7)
==1507==    by 0x202C08: std::__1::basic_streambuf<char,
std::__1::char_traits<char> >::sputn(char const*, long)
(include/c++/v1/streambuf:229)
==1507==    by 0x202A1F: std::__1::ostreambuf_iterator<char,
std::__1::char_traits<char> > std::__1::__pad_and_output<char,
std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char,
std::__1::char_traits<char> >, char const*, char const*, char const*,
std::__1::ios_base&, char) (include/c++/v1/locale:1411)
==1507==    by 0x202725: std::__1::basic_ostream<char,
std::__1::char_traits<char> >& std::__1::__put_character_sequence<char,
std::__1::char_traits<char> >(std::__1::basic_ostream<char,
std::__1::char_traits<char> >&, char const*, unsigned long)
(include/c++/v1/ostream:730)
==1507==    by 0x20260B: std::__1::basic_ostream<char,
std::__1::char_traits<char> >& std::__1::operator<<
<std::__1::char_traits<char> >(std::__1::basic_ostream<char,
std::__1::char_traits<char> >&, char const*) (include/c++/v1/ostream:869)


While looking at this, it strikes me that I'm not reading the libc debuginfo. I
need to investigate that.

-- 
You are receiving this mail because:
You are the assignee for the bug.