handling dll issue popup window - c++

Am trying to use the project found here, I have made some modifications and the code works okey, but sometimes it throws the below error.
How can I suppress or handle that error message in code, as it stops logic flow from continuing untill the button is pressed manually
after debgugging abit, I can find the error is thrown in a delete line, it tries to delete a pointer and it prints std::bad_alloc then hangs

Related

"Pure virtual function call" does not interrupt game, closes it when I click OK

I'm writing a game in C++ with a little known game framework known as Proton SDK by Seth A. Robinson. I am getting a runtime error like the one shown below..
Runtime Error!
I don't get trapped in the debugger, and the game still runs just fine while the dialog is open, but when I click OK on the dialog, the game closes.
I'm unable to provide any code as I've not been able to track down the cause of this problem simply due to the fact that the error doesn't trip up the debugger, instead just closes the program when I click OK and keeps it running while the dialog is open.
Other runtime errors show the usual abort, retry, cancel prompt, but this one just says "OK"?
I'm frustrated. I've been dealing with this issue for several months.

Is there something like non-catchable exception in C++?

I would like to terminate application when error occurs, something similar to throwing an exception that cannot be caught.
When C++ exception is thrown and not catched, Visual Studio 2017 automatically opens the file where exception is thrown and points to the exact line of exception in a text editor, which is exactly what I want, except that I would also like to prevent exception from being caught.
I tried using abort(0) and std::terminate(), but then a message box is shown, instead of pointing to the line in text editor where application is terminated.
Simillary, exit(0) only displays message to debugger output which says that application has exited.
Is there a way to terminate application, but still make Visual Studio point to the line in text editor where application is terminated?

TestStack White doesn't detect an SEHException

I'm writing a few tests for a managed/unmanaged Winform application. Some of the bugs occur in the unmanaged part, and result in the process terminating due to an unhandled System.Runtime.InteropServices.SEHException exception .
When this exception occurs, Windows pops up a message box explaining the error.
Unfortunately, neither MS Test nor White recognize this. The test itself finishes successfully without any sign of error, even though I can see the message box pop up right before the test goes on and closes the application.
How can I detect this kind of exception?
The message box is the result of the default unhandled exception handling of a Winforms application.
I ended up looking for it after the test has finished. If the message box is there, I fail the test.

Invalidate() debug assertion failed message (MFC, VC++)

I've made a custom control, and when I want it to repaint on the screen I call Invalidate(), and afterwards UpdateWindow(), but i get message:
debug assertion failed for a file afxwin2.inl in line 150 which is:
AFXWIN_INLINE void CWnd::Invalidate(BOOL bErase)
{ ASSERT(::IsWindow(m_hWnd)); ::InvalidateRect(m_hWnd, NULL, bErase); }
The thing is that when I run the same app in release mode, it doesn't report any message! So this clue makes me think it's about some environment configuration I should change.
What do you think?
Thanks.
Well,
ASSERT(::IsWindow(m_hWnd));
is an assertion. Assertions are statements which verify that something is true and kill your program if it's not. They're intended to be used for debugging and development rather than for being in the program once it has been released, so they are normally only compiled in in debug builds. So, it wouldn't be there in a release build, and you wouldn't get the error message. That does not mean that there isn't a problem in the release build. It just means that that it's not running the statement to check whether there's a problem.
I don't know a lot about the error in question, but looking at it,
::IsWindow(m_hWnd)
is obviously false (hence the error message). The documentation for IsWindow() would appear to indicate that the problem is that the window handle in question is not a handle for a valid window. Perhaps it hasn't been created properly, or it has already been destroyed. You'll have to figure out why your window handle is invalid.
A quick google search for "mfc iswindow" brings up this thread on msdn which might be of help to you.
You call Invalidate before window is created or after window is destroyed. Quick fix is to test for ::IsWindow(m_hWnd) before Invalidate call. To really fix this bug, find why Invalidate is called when window doesn't exist. For example, attempt to invalidate window from its constructor causes this assertion.
You have called Invalidate() on an CWnd-derived class, but that window's m_hWnd member has not been built yet. You should call the Create (or CreateEx) method first, in order to build it (or use a method that does all that for you, like DoModal() ).

Windows messages serviced whilst assert dialog is being displayed?

I have an MFC application that spawns a number of different worker threads and is compiled with VS2003.
When calling CTreeCtrl::GetItemState() I'm occasionally getting a debug assertion dialog popup. I'm assuming that this is because I've passed in a handle to an invalid item but this isn't my immediate concern.
My concern is: From my logs, it looks as though the MFC thread continues to service a number of windows messages whilst the assert dialog is being displayed. I thought the assert dialog was modal so I was wondering if this was even possible?
The message box that shows the assertion failure has a message pump for its own purposes. But it'll dispatch all messages that come in, not just those for the message box (otherwise things could get blocked).
With a normal modal dialog, this isn't a problem because the parent window is typically disabled for the duration of the dialog.
The code that launches the assertion dialog must've failed to figure out the parent window, and thus it wasn't disabled. This can happen if your main window isn't the active window at the time of the assertion. Other things can go wrong as well.
You can change how Visual Studio's C run-time library reports assertion failures with _CrtSetReportMode. You can make it stop in the debugger and/or log to the output window instead of trying to show the dialog.
Dialogs (even a messagebox) need to pump the message queue, even if they're modal. Otherwise how would they know you clicked on the "OK" button?
If you need to stop everything when an assert triggers it's usually not too difficult to write your own implementation of assert() (or ASSERT() or whatever) that will break into the debugger instead of displaying a messagebox that asks if you want to break into the debugger (maybe only if it determines that the debugger is attached).