Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"A breakpoint instruction (__debugbreak() statement or a similar call) was executed in Main.exe", but there is no error?

I have an infinite loop that breaks if user exits out of the main window. I have the following code running in the loop:

unsigned int* renderableShapeIndices = new unsigned int[aNumberCreatedAtRuntime];
// Do something
delete[] renderableShapeIndices;

Then the following happens a couple of loop iterations and cease to happen after the first iteration:

1st breakpoint:
A breakpoint instruction (__debugbreak() statement or a similar call) was executed in Main.exe.

2nd breakpoint:
Unhandled exception at 0x00007FF8C3B8C729 (ntdll.dll) in InTimeEngine2D.exe: 0xC0000374: A heap has been corrupted (parameters: 0x00007FF8C3BF7780).

Has anyone else gone through similar issues? I have no idea what is going on.

Another interesting factor about this is that it only happens in debug mode. It does not happen in release mode.

like image 293
Christopher Barrios Agosto Avatar asked Jan 28 '26 21:01

Christopher Barrios Agosto


1 Answers

The answer to the problem is in the comment section of the question.

Apparently, if one attempts to write to an array outside of its bounds, it will, but it ends up overwriting data of other places in the code, causing bugs in other parts of the program, even if these two parts of the program are unrelated. In my case, they were completely unrelated.

like image 147
Christopher Barrios Agosto Avatar answered Jan 30 '26 09:01

Christopher Barrios Agosto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!