Skip to content

Add compiler sanitizer options

Darshit Shah requested to merge gh-9457348d/77/darnir/cc-sanitize into master

Add some compiler -fsanitize options:

  1. Undefined Behaviour Sanitizer (ubsan): Detect issues in the code that are undefined behaviour according to the C specification
  2. Address Sanitizer (ASan): Detect addressing issues and memory leaks at runtime. Slightly similar to Valgrind, but using compiler added instrumentation

There's a couple of caveats to this set of patches:

  1. I've added the -fsanitize flags directly to the GCC Warnings in configure.ac. This means that any downstream maintainer that decides to enable warning flags will unknowingly enable these sanitization options as well. These options add instrumentation instructions to the compiled binary causing significant slowdown and will also cause crashes in many cases. As developers we want this, but end-users don't. We need to set up a new configure flag to enable such options.
  2. These don't seem to be working on Travis. The version of GCC is too old on travis to support these sanitization options. And with Clang, for some reason, Wget2 simply doesn't fail. On my system, the Address Sanitizer shows a couple of issues with the metalink test, but everything passes fine on Travis. I'll look deeper into it later, especially given how Travis currently has a few problems with newer Clang versions

Since this is turning to multiple small commits, I'll re-create this into a larger single patch after comments and suggestions

Merge request reports