Commit b215c6e4 authored by Davis King's avatar Davis King

Moved the dlib_assert_breakpoint() call in the assert macro to the front. This avoids

the case where your program has had its heap corrupted and is very nearly about to crash,
and so when an assert triggers it crashes on the code that constructs the error
message because the heap is hosed.  Thus preventing you from hitting a break point
on dlib_assert_breakpoint().  So this change mitigates that.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402580
parent 51e2396b
......@@ -69,13 +69,13 @@ namespace dlib
#define DLIB_CASSERT(_exp,_message) \
{if ( !(_exp) ) \
{ \
dlib_assert_breakpoint(); \
std::ostringstream dlib__out; \
dlib__out << "\n\nError occurred at line " << __LINE__ << ".\n"; \
dlib__out << "Error occurred in file " << __FILE__ << ".\n"; \
dlib__out << "Error occurred in function " << DLIB_FUNCTION_NAME << ".\n\n"; \
dlib__out << "Failing expression was " << #_exp << ".\n"; \
dlib__out << _message << "\n"; \
dlib_assert_breakpoint(); \
throw dlib::fatal_error(dlib::EBROKEN_ASSERT,dlib__out.str()); \
}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment