using ctest -T memcheck - corrupt log files?

ENVIRONMENT: Intel Core I5 running Rocky Linux 8 and Cmake/CTest 3.20.2

I include this in our top level CMakeLists.txt:

find_program(MEMORYCHECK_COMMAND valgrind)

We don’t have a dashboard server set up so I’m running the memory check with the command

ctest -T memcheck

Many of our tests don’t directly run the program under development, they run a script that runs the program. So we use –trace-children=yes to get tracing on the program we’re testing.

That mostly works, but I’m getting bizarre sequences of NUL characters dumped in the logfiles. This is NOT output from the program under test.

This makes it difficult to parse the log files to find actual valgrind error reports:

Hmm. It smells to me like something is long-truncating the file which then causes it to be filled with zeroes. Things to test:

  • does it happen outside of CTest (using the command CTest reports to run)? (to rule out ctest being the culprit)
  • can you get it to occur when running a simple “hello world” under valgrind? (to rule out your program)
  • does it happen without valgrind? (to rule it out)

If it still doesn’t show up, running under strace -f to find out where the write() or truncate() call is coming from would be the next step I think.

The big blobs of nulls happen in the MemoryChecker.n.log which are written by CTest when you do
ctest -T memcheck

I’ll try and track down what’s happening.