Skip to content

Commit b1caccf

Browse files
Fix strange behaviour
1 parent 76fd3ca commit b1caccf

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

utbot-framework/src/main/kotlin/org/utbot/engine/Traverser.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3261,12 +3261,12 @@ class Traverser(
32613261
queuedSymbolicStateUpdates += mkNot(mkEq(symbolicResult.value.addr, nullObjectAddr)).asHardConstraint()
32623262
}
32633263

3264-
val state = environment.state.update(queuedSymbolicStateUpdates)
3265-
val memory = state.memory
3266-
val solver = state.solver
3264+
val symbolicState = environment.state.symbolicState + queuedSymbolicStateUpdates
3265+
val memory = symbolicState.memory
3266+
val solver = symbolicState.solver
32673267

32683268
//no need to respect soft constraints in NestedMethod
3269-
val holder = solver.check(respectSoft = !state.isInNestedMethod())
3269+
val holder = solver.check(respectSoft = !environment.state.isInNestedMethod())
32703270

32713271
if (holder !is UtSolverStatusSAT) {
32723272
logger.trace { "processResult<${environment.method.signature}> UNSAT" }
@@ -3275,7 +3275,7 @@ class Traverser(
32753275
val methodResult = MethodResult(symbolicResult)
32763276

32773277
//execution frame from level 2 or above
3278-
if (state.isInNestedMethod()) {
3278+
if (environment.state.isInNestedMethod()) {
32793279
// static fields substitution
32803280
// TODO: JIRA:1610 -- better way of working with statics
32813281
val updates = if (environment.method.name == STATIC_INITIALIZER && substituteStaticsWithSymbolicVariable) {
@@ -3286,15 +3286,17 @@ class Traverser(
32863286
} else {
32873287
MemoryUpdate() // all memory updates are already added in [environment.state]
32883288
}
3289-
val stateToOffer = state.pop(methodResult.copy(symbolicStateUpdate = updates.asUpdate()))
3289+
val methodResultWithUpdates = methodResult.copy(symbolicStateUpdate = queuedSymbolicStateUpdates + updates)
3290+
val stateToOffer = environment.state.pop(methodResultWithUpdates)
32903291
offerState(stateToOffer)
32913292

32923293
logger.trace { "processResult<${environment.method.signature}> return from nested method" }
32933294
return
32943295
}
32953296

32963297
//toplevel method
3297-
val terminalExecutionState = state.copy(
3298+
val terminalExecutionState = environment.state.copy(
3299+
symbolicState = symbolicState,
32983300
methodResult = methodResult, // the way to put SymbolicResult into terminal state
32993301
label = StateLabel.TERMINAL
33003302
)

utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,7 @@ class UtBotSymbolicEngine(
468468
val solver = state.solver
469469
val parameters = state.parameters.map { it.value }
470470
val symbolicResult = requireNotNull(state.methodResult?.symbolicResult) { "The state must have symbolicResult" }
471-
// it's free to make a check, because in the result is SAT, it should be already cached
472-
val holder = requireNotNull(solver.check(respectSoft = true) as? UtSolverStatusSAT) { "The state must be SAT!" }
471+
val holder = requireNotNull(solver.lastStatus as? UtSolverStatusSAT) { "The state must be SAT!" }
473472

474473
val predictedTestName = Predictors.testName.predict(state.path)
475474
Predictors.testName.provide(state.path, predictedTestName, "")

0 commit comments

Comments
 (0)