Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Oct 2021 06:10:37 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 259294] [libc] add a freeres function
Message-ID:  <bug-259294-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D259294

            Bug ID: 259294
           Summary: [libc] add a freeres function
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: pjfloyd@wanadoo.fr

Summary
~~~~~~~

This is a request to add a freeres function to libc.


Motivation
~~~~~~~~~~

This function would be used by Valgrind (and conceivably other similar tool=
s).
The purpose is to free any "still reachable" memory on a clean exit. For
instance, this would include buffers allocated for I/O.

The freeres function doesn't get called by libc and in fact never gets call=
ed
for applications running in a regular environment. However, Valgrind will l=
ook
to see if it is present and call it (unless a command line flag has been
specified not to do so).

Current Status
~~~~~~~~~~~~~~

On Linux, GNU libc has such a function (as  does libstdc++,__gnu_cxx::__fre=
eres
).

On FreeBSD, libc++ does not allocate any buffers whose lifetime is not mana=
ged
by the runtime. The libstdc++ function __gnu_cxx::__freeres is used in the =
same
way as it is on Linux.

For FreeBSD libc, the default suppression mechanism is used. Whilst this is=
 a
reasonable solution, some users seem to find it disturbing and want to see
strictly zero leaks/memory use in the final summary.


This means that a 'printf("Hell, World!\n");' C application will have the
following summary from Valgring memcheck of FreeBSD

=3D=3D76307=3D=3D HEAP SUMMARY:
=3D=3D76307=3D=3D     in use at exit: 4,096 bytes in 1 blocks
=3D=3D76307=3D=3D   total heap usage: 1 allocs, 0 frees, 4,096 bytes alloca=
ted
=3D=3D76307=3D=3D=20
=3D=3D76307=3D=3D LEAK SUMMARY:
=3D=3D76307=3D=3D    definitely lost: 0 bytes in 0 blocks
=3D=3D76307=3D=3D    indirectly lost: 0 bytes in 0 blocks
=3D=3D76307=3D=3D      possibly lost: 0 bytes in 0 blocks
=3D=3D76307=3D=3D    still reachable: 0 bytes in 0 blocks
=3D=3D76307=3D=3D         suppressed: 4,096 bytes in 1 blocks

On Linux, the "in use at exit" is 0 and there is no "suppressed" line at the
end.

--=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-259294-227>