# using ctest -T memcheck - corrupt log files?

**URL:** https://discourse.cmake.org/t/using-ctest-t-memcheck-corrupt-log-files/5689
**Category:** Usage
**Created:** [May 18, 2022, 1:46pm UTC](https://discourse.cmake.org/t/using-ctest-t-memcheck-corrupt-log-files/5689 "2022-05-18T13:46:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![KentWilliams](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/c4cdca/32.png) [@KentWilliams](https://discourse.cmake.org/u/KentWilliams)
#### Post date: [May 18, 2022, 1:46pm UTC](https://discourse.cmake.org/t/using-ctest-t-memcheck-corrupt-log-files/5689/1 "2022-05-18T13:46:52Z")

</div>

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

I include this in our top level CMakeLists.txt:

```auto
find_program(MEMORYCHECK_COMMAND valgrind)
include(CTest)
enable_testing()

```

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:

 ![image](https://discourse.cmake.org/uploads/default/original/2X/c/c913d8107c20a52b6fa6c94e3304e84e093cb502.png)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 18, 2022, 2:54pm UTC](https://discourse.cmake.org/t/using-ctest-t-memcheck-corrupt-log-files/5689/2 "2022-05-18T14:54:04Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![KentWilliams](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/c4cdca/32.png) [@KentWilliams](https://discourse.cmake.org/u/KentWilliams)
#### Post date: [May 18, 2022, 3:13pm UTC](https://discourse.cmake.org/t/using-ctest-t-memcheck-corrupt-log-files/5689/3 "2022-05-18T15:13:12Z")

</div>

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.
