Skip to content

Commit

Permalink
[fix] Symcretes are updating now for new constraints if they had not …
Browse files Browse the repository at this point in the history
…been assigned before. Changed behaviour of conretization manager.
  • Loading branch information
S1eGa committed Dec 27, 2022
1 parent 21c3ddd commit 975eb21
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
7 changes: 6 additions & 1 deletion lib/Core/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,12 @@ void Executor::addConstraint(ExecutionState &state, ref<Expr> condition) {
klee_warning("seeds patched for violating constraint");
}

ConstraintSet oldCS = state.constraints;
state.addConstraint(condition);
if (cm->get(state.constraints).bindings.empty()) {
cm->add(Query(oldCS, condition), Assignment(true));
}

if (ivcEnabled)
doImpliedValueConcretization(state, condition,
ConstantExpr::alloc(1, Expr::Bool));
Expand Down Expand Up @@ -4866,7 +4871,6 @@ void Executor::executeMemoryOperation(ExecutionState &state,
}

if (bound) {
addConstraint(*bound, inBounds);
bound->addPointerResolution(base, address, mo);

/* FIXME: same as above. Wasting memory. */
Expand Down Expand Up @@ -4900,6 +4904,7 @@ void Executor::executeMemoryOperation(ExecutionState &state,
return;
}
if (mayBeOutOfBound) {
addConstraint(*unbound, checkOutOfBounds);
terminateStateOnError(*unbound, "memory error: out of bound pointer",
StateTerminationType::Ptr,
getAddressInfo(*unbound, address));
Expand Down
19 changes: 9 additions & 10 deletions lib/Solver/ConcretizationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,25 @@ void ConcretizationManager::add(const ConstraintSet &oldCS,
}
delete independent;

std::set<ref<Expr>> dependentWithNew;
ConstraintSet dependentWithNew;
ConstraintManager cm(dependentWithNew);

for (auto i : dependent) {
dependentWithNew.insert(i);
cm.addConstraint(i);
}

for (auto i : newCS) {
dependentWithNew.insert(i);
cm.addConstraint(i);
}

for (auto i : assign.bindings) {
newAssign.bindings.insert(i);
newAssign.bindings[i.first] = i.second;
}

concretizations.insert(dependentWithNew, newAssign);
concretizations.insert(dependentWithNew.asSet(), newAssign);
}

void ConcretizationManager::add(const Query &q, const Assignment &assign) {
std::vector<ref<Expr>> dependent;
getIndependentConstraints(q, dependent);
ConstraintSet newCS(dependent);
newCS.push_back(q.expr);
add({}, newCS, assign);
ConstraintSet newCS(std::vector<ref<Expr>>{q.expr});
add(q.constraints, newCS, assign);
}
4 changes: 0 additions & 4 deletions lib/Solver/ConcretizingSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ bool ConcretizingSolver::computeTruth(const Query &query, bool &isValid) {
// symcretes until remove all of them or query starts to evaluate
// to `mayBeFalse`.

if (isValid) {
cm->add(query, assign);
}

if (!isValid) {
cm->add(query.negateExpr(), assign);
}
Expand Down

0 comments on commit 975eb21

Please sign in to comment.