Issue
I use mtrace as mtrace example in archlinux manual, whereas it doesn't generate mtrace data file /tmp/t
.
mtrace info:
mtrace (GNU libc) 2.36
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Ulrich Drepper <[email protected]>
glibc info:
local/glibc 2.36-6
GNU C Library
gcc info:
gcc (GCC) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
archlinux info:
Linux ArchLinux 6.0.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 15 Oct 2022 14:00:49 +0000 x86_64 GNU/Linux
Solution
You need to add environment variable LD_PRELOAD=/usr/lib/libc_malloc_debug.so
(or similar depending on your libc path) when running the program.
I found this reported in the Arch bug tracker, which further links to glibc.git/NEWS
item, which says the following:
Debugging features in malloc such as the MALLOC_CHECK_ environment variable (or the glibc.malloc.check tunable), mtrace() and mcheck() have now been disabled by default in the main C library. Users looking to use these features now need to preload a new debugging DSO libc_malloc_debug.so to get this functionality back.
Answered By - M. Volf Answer Checked By - Clifford M. (WPSolving Volunteer)