Don't reconstruct expression on encountering fatal error

In some cases, like when given

```cpp
std::vector<char>* str =
reinterpret_cast<std::vector<char>*>(0x1234458);
CHECK(*str == std::vector<char>());
```

reconstructing the expression to report it would cause another fatal
error. Instead we just put together an AssertionResult without
reconstructing the expression fully.

This should fully fix #810
This commit is contained in:
Martin Hořeňovský 2017-03-02 18:18:28 +01:00
parent 40f6a5b8a4
commit cd6de9cd34
2 changed files with 8 additions and 5 deletions

View File

@ -53,7 +53,6 @@ namespace Catch {
static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) {
for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) {
reset();
reportFatal(signalDefs[i].name); reportFatal(signalDefs[i].name);
} }
} }

View File

@ -224,10 +224,14 @@ namespace Catch {
} }
virtual void handleFatalErrorCondition( std::string const& message ) { virtual void handleFatalErrorCondition( std::string const& message ) {
ResultBuilder resultBuilder = makeUnexpectedResultBuilder(); // Don't rebuild the result -- the stringification itself can cause more fatal errors
resultBuilder.setResultType( ResultWas::FatalErrorCondition ); // Instead, fake a result data.
resultBuilder << message; AssertionResultData tempResult;
resultBuilder.captureExpression(); tempResult.resultType = ResultWas::FatalErrorCondition;
tempResult.message = message;
AssertionResult result(m_lastAssertionInfo, tempResult);
getResultCapture().assertionEnded(result);
handleUnfinishedSections(); handleUnfinishedSections();