0

While working on one open source project, I performed a build in two ways:

  1. Cmake Debug Build with sanitizers enabled(Address, Memory, Thread, UB).
  2. Regular Cmake Debug build.

This is running on an Ubuntu 18.04 machine off of Parallels.

When running valgrind --leak-check=full <execute all unit tests>, Case 1, first gives the warning ==25464== Warning: set address range perms: large range [0x8f21000, 0x24c75000) (defined) and then shows thousands of errors with a single error statement Conditional jump or move depends on uninitialised value(s).
On the other hand Case 2 shows 0 errors.

I'm not sure whether this is a legitimate problem or something introduced due to the sanitizers added? More details here

tangy
  • 3,056
  • 2
  • 25
  • 42
  • 1
    I don't think a sanitizer build is supposed to run with valgrind (memcheck). It's basically two similar tools trying to do the same things and stepping on each other. – Matthieu Brucher Dec 22 '18 at 22:42
  • So, if Valgrind doesnt report errors in Case 2 and the sanitizers dont report problems, I can be sure that this is an artifact introduced due to the sanitizers and no problem in the code itself? – tangy Dec 22 '18 at 22:44
  • Debug build (without Sanitizers) tends to initialize to zero uninitialized memory. – Jarod42 Dec 22 '18 at 22:50
  • @Jarod42 Im sorry I didnt fully get what you meant and its implications? – tangy Dec 22 '18 at 22:57
  • 1
    Not familiar with Valgrind and sanitizer (So cannot say if case 1 is real error or false positive), but default behavior of debug build (implicit initialization of variable/buffer to 0) might hide code error(case 2). So code might have a problem even if not detected in case 2. – Jarod42 Dec 22 '18 at 23:25
  • I did not know that(implicit zero init in debug builds) - is there some reference you could point me to where I could read more about this? Also then a simple way to check against it is to run valgrind against a release build? – tangy Dec 22 '18 at 23:29
  • Sorry, don't have reference, quick search give value from Msvc which are not zero ([when-and-why-will-an-os-initialise-memory-to-0xcd-0xdd-etc-on-malloc-free-new](https://stackoverflow.com/questions/370195/when-and-why-will-an-os-initialise-memory-to-0xcd-0xdd-etc-on-malloc-free-new)) or vague explanation ([why-are-local-variables-initialized-to-0-in-g-compiler-for-c-in-ubuntu-linux](https://stackoverflow.com/questions/11143354/why-are-local-variables-initialized-to-0-in-g-compiler-for-c-in-ubuntu-linux)) – Jarod42 Dec 23 '18 at 00:15
  • @Jarod42 "Debug build tends to initialize to zero uninitialized memory" - this is a very strong statement, please provide prooflinks. – yugr Dec 23 '18 at 09:23

0 Answers0