File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -422,6 +422,11 @@ ConstraintSystem::SolverState::~SolverState() {
422
422
" Expected constraint system to have this solver state!" );
423
423
CS.solverState = nullptr ;
424
424
425
+ // If constraint system ended up being in an invalid state
426
+ // let's just drop the state without attempting to rollback.
427
+ if (CS.inInvalidState ())
428
+ return ;
429
+
425
430
// Make sure that all of the retired constraints have been returned
426
431
// to constraint system.
427
432
assert (!hasRetiredConstraints ());
@@ -513,6 +518,10 @@ ConstraintSystem::SolverScope::SolverScope(ConstraintSystem &cs)
513
518
}
514
519
515
520
ConstraintSystem::SolverScope::~SolverScope () {
521
+ // Don't attempt to rollback from an incorrect state.
522
+ if (cs.inInvalidState ())
523
+ return ;
524
+
516
525
// Erase the end of various lists.
517
526
while (cs.TypeVariables .size () > numTypeVariables)
518
527
cs.TypeVariables .pop_back ();
Original file line number Diff line number Diff line change @@ -37,7 +37,14 @@ using namespace constraints;
37
37
ConstraintGraph::ConstraintGraph (ConstraintSystem &cs) : CS(cs) { }
38
38
39
39
ConstraintGraph::~ConstraintGraph () {
40
- assert (Changes.empty () && " Scope stack corrupted" );
40
+ #ifndef NDEBUG
41
+ // If constraint system is in an invalid state, it's
42
+ // possible that constraint graph is corrupted as well
43
+ // so let's not attempt to check change log.
44
+ if (!CS.inInvalidState ())
45
+ assert (Changes.empty () && " Scope stack corrupted" );
46
+ #endif
47
+
41
48
for (unsigned i = 0 , n = TypeVariables.size (); i != n; ++i) {
42
49
auto &impl = TypeVariables[i]->getImpl ();
43
50
delete impl.getGraphNode ();
@@ -412,6 +419,11 @@ ConstraintGraphScope::ConstraintGraphScope(ConstraintGraph &CG)
412
419
}
413
420
414
421
ConstraintGraphScope::~ConstraintGraphScope () {
422
+ // Don't attempt to rollback if constraint system ended up
423
+ // in an invalid state.
424
+ if (CG.CS .inInvalidState ())
425
+ return ;
426
+
415
427
// Pop changes off the stack until we hit the change could we had prior to
416
428
// introducing this scope.
417
429
assert (CG.Changes .size () >= NumChanges && " Scope stack corrupted" );
You can’t perform that action at this time.
0 commit comments