Process.WaitForExit not starting with __debugbreak

I am trying to write a program to test student code with a good implementation. I have a C ++ console application that will run one test at a time, defined by command line commands, and a C # .net forms application that calls the C ++ application once for each test. The goal is to be able to detect not only a skip / failure for each test, but also an β€œendless” (> 5 seconds) loop and exceptions (their code dies for any reason).

The problem is that not all errors kill a C ++ application. If they damage the heap, the system calls __debugbreak, which displays a window with the message "Debugging error"! HEAP CORRUPTION DETECTED ... My C # application uses Process.WaitForExit (5000) to wait, but this error is not considered an output, so I see a timeout.

So my question is: how can I make a C # application detect that this is an error? Or how can I make a C ++ application die when this error occurs, rather than giving a dialog box and asking if I want to debug

Edit:
Here is the error that appears: Debugging error

A dialog box appears with a normal application that appears if I click repeat in the previous dialog box: Windows error . The debugging option disappears if you disable the JIT debugger.

+3
source share
2 answers

You must enable JIT debugging, this page contains instructions for enabling or disabling it.

_ CrtSetReportMode _ CrtSetReportFile ++, ( , _CRTDBG_MODE_FILE .

, .cpp , , . - :

// AssertModify.cpp
class AssertModify
{
public:
    AssertModify()
    {
        ::_CrtSetReportMode(...);
        ::_CrtSetReportFile(...);
    }
};

AssertModify am;

, main(), ( , _CrtSetReportMode )

+1

, ++ "release". , "" , . MessageBoxes, .

, ( ), . # , , .

0

Source: https://habr.com/ru/post/1738901/


All Articles