[cmake-developers] Fw: CTest and Address Sanitizer

Karl Robinson debuggery at outlook.com
Thu Jan 5 20:21:11 EST 2017


Hi Chuck


Firstly, thanks for taking the time to respond.


The sanitizers exit on failure thing makes perfect sense although why it isn't the default behavior mystifies me. Turning it on gets me the effect I am looking for (CTest can detect a failure) but what I really want to know and the reason for my original post is:


1) Why do I always get Valgrind when I run memtest? Either that or "Memory checker (MemoryCheckCommand) not set, or cannot find the specified program.". Looking at the source code I _think_ setting  the MEMORYCHECK_TYPE variable to AddressSanitizer should be enough, I shouldn't need to set the MemoryCheckCommand and there isn't one for the sanitizers anyway


2) The documentation hints that CTest should be able to understand the output of the sanitizers, I can't say if this true or not with any certainty but it doesn't seem to be the case


Thanks again!


________________________________
From: Chuck Atkins <chuck.atkins at kitware.com>
Sent: Thursday, January 5, 2017 11:47:13 AM
To: Karl Robinson
Cc: cmake-developers at cmake.org
Subject: Re: [cmake-developers] Fw: CTest and Address Sanitizer

Hi Karl,

>> I believe that the AddressSanitizer should normally stop with a non-zero error code right after the first error.

I have many tests within each executable test application, forcing the application to exit on the first error is not optimal since it means I cannot get an overview of all the issues and triage/fix them in logical order. Instead I have to test/fix/retest every time


That's by design and isn't to do with how CMake integrates asan; i.e. it's just how asan works.  The idea being that once you hit a memory corruption then any further results can't be relied on.  From the asan documentation: http://clang.llvm.org/docs/AddressSanitizer.html

"If a bug is detected, the program will print an error message to stderr and exit with a non-zero exit code. AddressSanitizer exits on the first detected error. This is by design:

  *   This approach allows AddressSanitizer to produce faster and smaller generated code (both by ~5%).
  *   Fixing bugs becomes unavoidable. AddressSanitizer does not produce false alarms. Once a memory corruption occurs, the program is in an inconsistent state, which could lead to confusing results and potentially misleading subsequent reports.

"

- Chuck


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20170106/69a9fa2a/attachment.html>


More information about the cmake-developers mailing list