From 381f720c29b5d098065924022851c0a39f95211d Mon Sep 17 00:00:00 2001 From: otto <> Date: Fri, 30 Jun 2023 06:24:58 +0000 Subject: Recommit "Allow to ask for deeper callers for leak reports using malloc options" Now only enabled for platforms where it's know to work and written as a inline functions instead of a macro. --- src/lib/libc/stdlib/malloc.3 | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/lib/libc/stdlib/malloc.3') diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3 index 79e85f39ee..88a8264da5 100644 --- a/src/lib/libc/stdlib/malloc.3 +++ b/src/lib/libc/stdlib/malloc.3 @@ -30,9 +30,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $OpenBSD: malloc.3,v 1.135 2023/06/23 05:26:45 otto Exp $ +.\" $OpenBSD: malloc.3,v 1.136 2023/06/30 06:24:58 otto Exp $ .\" -.Dd $Mdocdate: June 23 2023 $ +.Dd $Mdocdate: June 30 2023 $ .Dt MALLOC 3 .Os .Sh NAME @@ -294,6 +294,17 @@ To record the dump: To view the leak report: .Pp .Dl $ kdump -u malloc ... +.Pp +By default, the immediate caller of a +.Nm +function will be recorded. +Use malloc options +.Cm 2 +or +.Cm 3 +to record the caller one or two stack frames deeper instead. +These malloc options imply +.Cm D . .It Cm F .Dq Freecheck . Enable more extensive double free and use after free detection. @@ -813,3 +824,14 @@ and .Fn realloc to avoid these problems on .Ox . +.Pp +The mechanism to record caller functions when using malloc options +.Cm 2 +or +.Cm 3 +is not guaranteed to work for all platforms, compilers or compilation +options, +and might even crash your program. +Use +.Em only +for debugging purposes. -- cgit v1.2.3-55-g6feb