Why is my C ++ program crashing with exit code 11 when I remove the cout statement?

In my C ++ project, I am having a very strange problem. It crashes with exit code 11 when I remove a specific log statement ( cout

).

This answer points to a source that explains exit code 11 (actually EAGAIN

) with the following statement:

The system did not have the necessary resources to create another thread, or the system limit on the total number of threads in the PTHREAD_THREADS_MAX process will be exceeded.

But I'm pretty sure I'm not creating any additional threads in my code (at least not explicitly). So why is the error occurring and why does it go away when I use the log statement?

For reference, I'll post the code, but it is of course completely out of context, and basically the only relevant line is the one with the log statement.

 PayloadRegionMapper(string mappingTechniqueName, string configPath = "")
    : payload(PAYLOAD), config(Config(configPath)) {

    cout << "construct PayloadRegionMapper" << endl; // if commented out, my program crashes....

    frames = generateFrames();
    setMappingTechnique(mappingTechniqueName);
}

      

+3


source to share


1 answer


Run the program with the debugger and then backtrack after the crash. Using the bt and frame commands, you can get an idea of ​​the program's behavior during an emergency.



gdb <executable>

.....<crash happened>

bt
<It will give you the stack frame >

frame <frame number>

Then look for the values and memory area there. 

      

0


source







All Articles