Question

So this is very strange and there might be a really simple explanation for this, but I'm using a machine I don't normally develop on with a factory-default installation of VS 2010. The code posted below is exactly what I am running, and it's causing this familiar message:

Windows has triggered a breakpoint in ProjectB.exe.

This may be due to a corruption of the heap, which indicates a bug in ProjectB.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while ProjectB.exe has focus.

The output window may have more diagnostic information.

The code is:

#include <iostream>
#include <cstdlib>
using namespace std;

int main( int argc, char** argv )
{
    system( "pause" );
    return 0;
}

That's it! Nothing more and only one file. Commenting out system( "pause" ) doesn't trigger the break, but I can't stop the program from exiting (as you would expect). So I'm really confused. This just seems really strange to me, as I've never experienced this before and I don't understand why this causes an issue. Using another system command that doesn't stop the process (like system( "cls" )) doesn't cause the problem, either. My inclination is that this is specific to the machine I'm working on, but I'm not sure. Thanks in advance!

Any help is appreciated.

[EDIT]

So I've never debugged into the standard headers (at least not purposefully) before, but I noticed one thing:

In __crtCorExitProcess the call to load the mscoree.dll module returns a null handle, meaning it's not loaded. I'm not sure if that's what normally happens, but in doing so it skips a block of code that gets the exit proc function pointer. It is after this method is called that a call to ExitProcess is called, and it is from here that the break is triggered.

[EDIT 2]

The following is produced in the output window after the call the system( "pause" ): First-chance exception at 0x750cc41f in ProjectB.exe: Microsoft C++ exception: >log4cxx::helpers::IOException at memory location 0x006ff1fc.. First-chance exception at 0x750cc41f in ProjectB.exe: Microsoft C++ exception: >log4cxx::helpers::IOException at memory location 0x006ff344.. SPLogger: setFile(C:\ProgramData\Safend\Logs.18698\SPHook.log,true) call failed. SPLogger: IO Exception : status code = 720005 SPLogger: No output stream or file set for the appender named [SPHookLog].

And then when ExitProcess is called, this is added to the output window:

The thread 'Win32 Thread' (0x1ca8) has exited with code 0 (0x0). HEAP[ProjectB.exe]: HEAP: Free Heap block 21a4ba8 modified at 21a4c10 after it was freed

Which is curious to me.

Was it helpful?

Solution

I believe the issue here is that there is security software running that is preventing certain DLL's from being loaded and/or injecting code to prevent malicious instructions from being executed. Since I've never experienced this on a personal machine and am only experiencing this on a corporate box that has a lot of security administration going on, I think it is that. I doubt it is a runtime mismatch, as nothing else produces unexpected results. Thank you everyone who commented with potential problems! Read the comments if you're having this issue, as there are other potential issues discussed there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top