title: Why does my program occasionally segfault when out of memory rather than throwing std::bad_alloc?
body: <p>I have a program that implements several heuristic search algorithms and several domains, designed to experimentally evaluate the various algorithms.  The program is written in C++, built using the GNU toolchain, and run on a 64-bit Ubuntu system.  When I run my experiments, I use bash's <code>ulimit</code> command to limit the amount of virtual memory the process can use, so that my test system does not start swapping.</p>
  
  <p>Certain algorithm/test instance combinations hit the memory limit I have defined.  Most of the time, the program throws an std::bad_alloc exception, which is printed by the default handler, at which point the program terminates.  Occasionally, rather than this happening, the program simply segfaults.</p>
  
  <p>Why does my program occasionally segfault when out of memory, rather than reporting an unhandled std::bad_alloc and terminating?</p>