Reputation: 8816
I would like to replace any standard error-dialog with throw
or debug-break
(with standard I mean anything which is not explicitly written by me) since like in the reason-section described, it would cause debugging of a Windows-Service sometimes to be impossible.
to accomplish this I did try defining something like:
-D "_HAS_ITERATOR_DEBUGGING=0"
but above did just disable the error-dialogs and is really not enough to track down the issues, so I would like it to throw-exception
or to debug-break
instead of showing the error-dialog.
is there anything else you would suggest me to define or do?
While developing a Windows-Service, I had some hard times to find a bug which was causing the server to crash:
std::unordered_map
usagestd::unordered_map
which tried to show an error message-box (since compiled in debug-mode)git
history and rechecking all recent changes was it possible to find the issueby running below in a service (compiled in debug-mode) you can reproduce this issue:
#include <unordered_map>
// will cause crash by trying to increment iterator pointing to end
inline static void simulateCrash() {
typedef std::unordered_map<quint32, quint32> Hash;
Hash list;
list[0xC001] = 0xDEAD;
Hash::iterator it = list.begin();
it = list.erase(it);
++it; // should crash here
}
Upvotes: 1
Views: 99
Reputation: 218138
You probably want to use _set_invalid_parameter_handler
to overwrite default handler which terminates the program and displays a runtime error message.
_CrtSetReportMode
is also useful to avoid dialog from _CrtDbgReport
(used in several checks).
Upvotes: 2