title: segfault not caught in gdb nor valgrind
body: <p>I have a fairly big code written in c++ (not by me).
  The code has been working fine for the most part, until I upgraded the system where it is running to a newer version of debian (bullseye).</p>
  <p>We are getting a segfault when one specific operation of the code is executed.</p>
  <p>I get the segfault with the code compiled in both optimized and debug flavors.</p>
  <p>However, when I run the code with either gdb or valgrind, the code works fine. Valgrind doesn't show any errors.</p>
  <p>The last thing I tried was running the code <em>without</em> gdb/valgrind and generating a core dump. Opening the core dump with gdb shows that the segfault happens when I call realloc(), so apparently something is messing up that pointer when it is freed. I tried replacing the realloc by a malloc() followed by a memcpy() (without freeing the previous pointer), and it worked fine.</p>
  <p>I was reading in other blogs and it might be that both gdb and valgrind change the memory layout of the code so the bug doesn't show up, so if that's the case, how can I track it ?
  Any suggestions would be greatly appreciated!</p>