title: Why does my C++ program crash with exit code 11 when I remove a cout statement?
body: <p>In my C++ project, I encounter a very strange issue. It crashes with <em>exit code 11</em> when I <em>remove</em> a certain log statement (<code>cout</code>). </p>
  
  <p><a href="https://stackoverflow.com/questions/7038586/return-code-from-pthread-create-is-11">This answer</a> points to a source that explains exit code 11 (actually <code>EAGAIN</code>) with the following statement:</p>
  
  <blockquote>
    <p>The system lacked the necessary resources to create another thread, or
    the system-imposed limit on the total number of threads in a process
    PTHREAD_THREADS_MAX would be exceeded.</p>
  </blockquote>
  
  <p>But I am pretty sure don't create any additional threads in my code (at least not explicitly). So why does the error occur and why does it go away when I use the log statement?</p>
  
  <p>For reference, I will post the code but it's of course completely out of context and basically the only relevant line is the one with the log statement.</p>
  
  <pre><code> PayloadRegionMapper(string mappingTechniqueName, string configPath = "")
      : payload(PAYLOAD), config(Config(configPath)) {
  
      cout &lt;&lt; "construct PayloadRegionMapper" &lt;&lt; endl; // if commented out, my program crashes....
  
      frames = generateFrames();
      setMappingTechnique(mappingTechniqueName);
  }
  </code></pre>