Search code examples
cvalgrindmtrace

Can mtrace be successfully run with valgrind?


I have a program which does 5 mallocs and 3 frees. I call mtrace() at the start and muntrace() at the end. mtrace will report the missing frees if I run the program normally. If I do:

valgrind -v --log-file=val.log --leak-check=full --show-reachable=yes my_program

valgrind will report the missing frees but mtrace will not.

So I guess you can't use them both together - valgrind will override mtrace?


Solution

  • So I guess you can't use them both together

    Correct.

    valgrind will override mtrace?

    I don't believe Valgrind overrides mtrace, but it does override malloc and free, so mtrace simply never sees either malloc of free.