FS#76435 - [glibc] mtrace() not working

Attached to Project: Arch Linux
Opened by Raman Mohan (mohan43u) - Saturday, 05 November 2022, 19:48 GMT
Last edited by Toolybird (Toolybird) - Friday, 15 September 2023, 06:39 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To freswa (frederik)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
mtrace() suppose to use MALLOC_TRACE environment variable to open the trace file and add trace about head memory usage. but its not happening. I also added '#define _GNU_SOURCE' at the beginning, not working

example test.c:

#define _GNU_SOURCE
#include <mcheck.h>

int main(int argc, char *argv[]) {
char *buffer = NULL;
buffer = calloc(1, 1000);
free(buffer);
return 0;
}

compile:
$ gcc -o test test.c

command which I used to run the test:
$ (export MALLOC_TRACE=$(pwd)/test.mtrace; ./test)

Someone also noticed this here https://stackoverflow.com/questions/74136501/mtrace-doesnt-generate-mtrace-data-file-in-archlinux-but-works-in-debian

Additional info:
* package version(s): 2.36-6
This task depends upon

Closed by  Toolybird (Toolybird)
Friday, 15 September 2023, 06:39 GMT
Reason for closing:  Upstream
Additional comments about closing:  See comments
Comment by freswa (frederik) - Saturday, 05 November 2022, 20:01 GMT
Could you report this upstream please?
Comment by Toolybird (Toolybird) - Saturday, 05 November 2022, 23:28 GMT
It's by design. Please see [1]. I suppose the man page needs updating. You can get it to work by:

$ LD_PRELOAD=/usr/lib/libc_malloc_debug.so ./foo

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS;h=a10bb08fb09cf7d323826cc66bdd665232c1ed96;hb=HEAD#l723
Comment by Toolybird (Toolybird) - Friday, 15 September 2023, 06:39 GMT
The man page in question [1] comes from the "man-pages" project [2]. Any issues should therefore be reported there.

[1] https://man.archlinux.org/man/mtrace.3.en#EXAMPLES
[2] https://www.kernel.org/doc/man-pages/

Loading...