Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions lib/Core/TargetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,23 @@ bool TargetManager::isReachedTarget(const ExecutionState &state,
}

if (target->shouldFailOnThisTarget()) {
if (state.pc->parent == target->getBlock()) {
if (cast<ReproduceErrorTarget>(target)->isTheSameAsIn(state.prevPC) &&
cast<ReproduceErrorTarget>(target)->isThatError(state.error)) {
bool found = true;
auto possibleInstruction = state.prevPC;
int i = state.stack.size() - 1;

while (!cast<ReproduceErrorTarget>(target)->isTheSameAsIn(
possibleInstruction)) { // TODO: target->getBlock() ==
// possibleInstruction should also be checked,
// but more smartly
if (i <= 0) {
found = false;
break;
}
possibleInstruction = state.stack.callStack().at(i).caller;
i--;
}
if (found) {
if (cast<ReproduceErrorTarget>(target)->isThatError(state.error)) {
result = Done;
} else {
result = Continue;
Expand Down
22 changes: 3 additions & 19 deletions lib/Core/TargetedExecutionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ void TargetedExecutionManager::reportFalseNegative(ExecutionState &state,
bool TargetedExecutionManager::reportTruePositive(ExecutionState &state,
ReachWithError error) {
bool atLeastOneReported = false;
state.error = error;
for (auto target : state.targetForest.getTargets()) {
if (!target->shouldFailOnThisTarget())
continue;
Expand All @@ -539,27 +540,10 @@ bool TargetedExecutionManager::reportTruePositive(ExecutionState &state,
reportedTraces.count(errorTarget->getId()))
continue;

/// The following code checks if target is a `call ...` instruction and we
/// failed somewhere *inside* call
auto possibleInstruction = state.prevPC;
int i = state.stack.size() - 1;
bool found = true;

while (!errorTarget->isTheSameAsIn(
possibleInstruction)) { // TODO: target->getBlock() ==
// possibleInstruction should also be checked,
// but more smartly
if (i <= 0) {
found = false;
break;
}
possibleInstruction = state.stack.callStack().at(i).caller;
i--;
}
if (!found)
if (!targetManager.isReachedTarget(state, errorTarget)) {
continue;
}

state.error = error;
atLeastOneReported = true;
assert(!errorTarget->isReported);
if (errorTarget->isThatError(ReachWithError::Reachable)) {
Expand Down
2 changes: 1 addition & 1 deletion test/Industry/if2.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main(int x) {
// REQUIRES: z3
// RUN: %clang %s -emit-llvm -c -g -O0 -Xclang -disable-O0-optnone -o %t1.bc
// RUN: rm -rf %t.klee-out
// RUN: %klee --output-dir=%t.klee-out --use-guided-search=error --mock-external-calls --skip-not-symbolic-objects --skip-not-lazy-initialized --check-out-of-memory --search=bfs --max-stepped-instructions=19 --max-cycles-before-stuck=0 --use-lazy-initialization=only --analysis-reproduce=%s.json %t1.bc
// RUN: %klee --output-dir=%t.klee-out --use-guided-search=error --mock-external-calls --skip-not-symbolic-objects --skip-not-lazy-initialized --check-out-of-memory --search=bfs --max-stepped-instructions=20 --max-cycles-before-stuck=0 --use-lazy-initialization=only --analysis-reproduce=%s.json %t1.bc
// RUN: FileCheck -input-file=%t.klee-out/warnings.txt %s -check-prefix=CHECK-NONE
// CHECK-NONE: KLEE: WARNING: 50.00% NullPointerException False Positive at trace 1
// RUN: FileCheck -input-file=%t.klee-out/messages.txt %s -check-prefix=CHECK-DISTANCE
Expand Down