De ez le is van írva: az mtrace() az nem thread-safe library.
Itt egy 13 éves hibajegy erről: https://bugzilla.redhat.com/show_bug.cgi?id=241665
mtrace is inherently thread unsafe due to the use of malloc hooks....
In summary, for multithreaded programs use valgrind instead of mtrace.
A dokumentációja szerint ( https://www.gnu.org/software/libc/manual/html_node/Tracing-malloc.html#… ):
MT-Unsafe env race:mtrace const:malloc_hooks init