@@ -48,14 +48,12 @@ import org.utbot.instrumentation.ConcreteExecutor
48
48
import org.utbot.instrumentation.instrumentation.Instrumentation
49
49
import org.utbot.instrumentation.instrumentation.execution.UtConcreteExecutionData
50
50
import org.utbot.instrumentation.instrumentation.execution.UtConcreteExecutionResult
51
- import org.utbot.instrumentation.instrumentation.execution.UtExecutionInstrumentation
52
51
import org.utbot.taint.*
53
52
import org.utbot.taint.model.TaintConfiguration
54
53
import soot.jimple.Stmt
55
54
import soot.tagkit.ParamNamesTag
56
55
import java.lang.reflect.Method
57
56
import java.util.function.Consumer
58
- import java.util.function.Predicate
59
57
import kotlin.math.min
60
58
import kotlin.system.measureTimeMillis
61
59
@@ -317,10 +315,7 @@ class UtBotSymbolicEngine(
317
315
val concreteExecutionResult =
318
316
concreteExecutor.executeConcretely(methodUnderTest, stateBefore, instrumentation, UtSettings .concreteExecutionDefaultTimeoutInInstrumentedProcessMillis)
319
317
320
- concreteExecutionResult.processedFailure()?.let { failure ->
321
- emitFailedConcreteExecutionResult(stateBefore, failure.exception)
322
-
323
- logger.debug { " Instrumented process failed with exception ${failure.exception} before concrete execution started" }
318
+ if (failureCanBeProcessedGracefully(concreteExecutionResult, executionToRollbackOn = null )) {
324
319
return @measureTime
325
320
}
326
321
@@ -668,10 +663,7 @@ class UtBotSymbolicEngine(
668
663
UtSettings .concreteExecutionDefaultTimeoutInInstrumentedProcessMillis
669
664
)
670
665
671
- concreteExecutionResult.processedFailure()?.let { failure ->
672
- emitFailedConcreteExecutionResult(stateBefore, failure.exception)
673
-
674
- logger.debug { " Instrumented process failed with exception ${failure.exception} before concrete execution started" }
666
+ if (failureCanBeProcessedGracefully(concreteExecutionResult, symbolicUtExecution)) {
675
667
return
676
668
}
677
669
@@ -699,6 +691,29 @@ class UtBotSymbolicEngine(
699
691
}
700
692
}
701
693
694
+ private suspend fun FlowCollector<UtResult>.failureCanBeProcessedGracefully (
695
+ concreteExecutionResult : UtConcreteExecutionResult ,
696
+ executionToRollbackOn : UtExecution ? ,
697
+ ): Boolean {
698
+ concreteExecutionResult.processedFailure()?.let { failure ->
699
+ // If concrete execution failed to some reasons that are not process death or cancellation
700
+ // when we call something that is processed successfully by symbolic engine,
701
+ // we should:
702
+ // - roll back to symbolic execution data ignoring failing concrete (is symbolic execution exists);
703
+ // - do not emit an execution if there is nothing to roll back on.
704
+
705
+ // Note that this situation is suspicious anyway, so we log a WARN message about the failure.
706
+ executionToRollbackOn?.let {
707
+ emit(it)
708
+ }
709
+
710
+ logger.warn { " Instrumented process failed with exception ${failure.exception} before concrete execution started" }
711
+ return true
712
+ }
713
+
714
+ return false
715
+ }
716
+
702
717
/* *
703
718
* Collects entry method statement path for ML. Eliminates duplicated statements, e.g. assignment with invocation
704
719
* in right part.
0 commit comments