title: Crash before main()
body: <p>My program crashes before main() function. I determine this using "cerr":</p>
  
  <pre><code>int main(int argc, char **argv)
  {
    cerr &lt;&lt; " MAAIN " &lt;&lt; endl;
  </code></pre>
  
  <p>The message from gdb:</p>
  
  <pre><code>   Reading symbols for shared libraries ...........+++............................ done
  CA(34652) malloc: *** error for object 0x7fff76694860: pointer being freed was not allocated
  *** set a breakpoint in malloc_error_break to debug
  
  Program received signal SIGABRT, Aborted.
  0x00007fff88e1782a in __kill ()
  (gdb) bt
  #0  0x00007fff88e1782a in __kill ()
  #1  0x00007fff8c4d2a9c in abort ()
  #2  0x00007fff8c53184c in free ()
  #3  0x00000001026a1db0 in std::basic_stringbuf&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::overflow ()
  (gdb) 
  </code></pre>
  
  <p>I have checked the code for "delete" and "free" functions. All deletes are done with check like this:</p>
  
  <pre><code>if (x) delete x;
  </code></pre>
  
  <p>Please help me with answering two questions:
  1. What can be the possible problem?
  2. How to find it? (I have a big code with a lot of files and cmake for compilation).</p>
  
  <p>P.S. I read <a href="https://stackoverflow.com/questions/2518415/is-there-any-way-a-c-c-program-can-crash-before-main">Is there any way a C/C++ program can crash before main()?</a>  but looking at gdb massage I suppose libraries are ok.</p>