Skip to content

More fixes for real applications #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 82 commits into from
Jul 3, 2025
Merged
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
ccc157d
Hacks
CaelmBleidd May 29, 2025
78a7f34
More hacks
CaelmBleidd May 29, 2025
bde9520
Some more fixes
CaelmBleidd May 30, 2025
4d0cf6b
Tmp commit
CaelmBleidd May 30, 2025
a4954f9
Input arrays support
CaelmBleidd Jun 6, 2025
5d4dc68
Format
Lipen Jun 9, 2025
7cf9061
Operators implementation
CaelmBleidd Jun 10, 2025
2a07286
Some hacks
CaelmBleidd Jun 10, 2025
8c9e9f4
Fix a class signature lookup
CaelmBleidd Jun 11, 2025
689a902
Support simple casts
CaelmBleidd Jun 11, 2025
760624b
Clear logs
CaelmBleidd Jun 11, 2025
4bd35ba
Add todo
CaelmBleidd Jun 11, 2025
ada1c48
Rebase fix
CaelmBleidd Jun 18, 2025
0dda9c0
Tmp changes
CaelmBleidd Jun 19, 2025
78a134d
Some fixes
CaelmBleidd Jun 20, 2025
0a79a2f
Fix mocker return value
CaelmBleidd Jun 20, 2025
9049cfc
Resolve external locals
Lipen Jun 25, 2025
399dd4d
Rename 'expr' arg in observer
Lipen Jun 25, 2025
0312be1
Format
Lipen Jun 25, 2025
e72ec32
Add special case for "Aux[length] is a supertype of Array"
Lipen Jun 25, 2025
09e8cb8
Handle EtsArrayType in 'classesForType'
Lipen Jun 25, 2025
733c861
Expand and re-construct ITE with fake branches
Lipen Jun 25, 2025
8c37276
Handle ptr call
Lipen Jun 25, 2025
336c4b2
Remove unnecessary doWithState
Lipen Jun 25, 2025
a63c041
USE CALLEE INSTEAD OF METHOD
Lipen Jun 25, 2025
5ce84c9
Do not warn about unresolved 'then' method
Lipen Jun 25, 2025
d863419
Cherry-pick main
Lipen Jun 25, 2025
3b09c31
Fix printing of exceptions
Lipen Jun 25, 2025
226cc5d
Support 'toString'
Lipen Jun 25, 2025
5a71b32
Format
Lipen Jun 25, 2025
e17b09e
Handle fake objects and ITE with fake branches
Lipen Jun 25, 2025
f0fd064
Fix virtual invokes
CaelmBleidd Jun 26, 2025
e1dbb62
Small dot modification
CaelmBleidd Jun 26, 2025
9990ff5
Add visualization
CaelmBleidd Jun 27, 2025
4a3fcc3
Add visualization
CaelmBleidd Jun 27, 2025
281a96c
Visualization
CaelmBleidd Jun 30, 2025
a577095
Visualization
CaelmBleidd Jun 30, 2025
e7e3757
Move test
CaelmBleidd Jun 30, 2025
63caf79
Fix arrays
CaelmBleidd Jun 30, 2025
c17d546
Fix type streams
CaelmBleidd Jul 1, 2025
3ab240e
Remove forking warning
Lipen Jul 1, 2025
0dd7796
Warn only when necessary
Lipen Jul 1, 2025
258a0d8
Refine operators
Lipen Jul 1, 2025
1b92d9c
Mark flaky test as repeated
Lipen Jul 1, 2025
61d633c
Make `withMode` generic extension
Lipen Jul 1, 2025
55f0a2f
Remove empty lines
Lipen Jul 1, 2025
d2e972b
Assert instance inside fake object is not null. Make tests more lenient
Lipen Jul 1, 2025
0e4b1a4
Unify
Lipen Jul 1, 2025
34dd6a5
Fix type stream tests
Lipen Jul 1, 2025
f59eb55
Use isSubtype+isSupertype
Lipen Jul 1, 2025
61ad560
Fix test with super
Lipen Jul 1, 2025
0014070
Add test with non-overridden virtual call
Lipen Jul 1, 2025
f6fe2da
Show stop reason
Lipen Jul 1, 2025
98964a9
Format
Lipen Jul 1, 2025
0616f03
Rename DemoPhotos
Lipen Jul 1, 2025
571386d
Cleanup
Lipen Jul 1, 2025
74b457c
Use constant
Lipen Jul 1, 2025
914dd43
Use timeout 120s
Lipen Jul 2, 2025
aa515cb
Add AnyType to top type stream, handle Any in isSupertype
Lipen Jul 2, 2025
52cfb93
Move dot utils
Lipen Jul 2, 2025
8853911
Format
Lipen Jul 2, 2025
ce6b957
Register callee for static initializer
Lipen Jul 2, 2025
fa44f6a
Filter some warnings
Lipen Jul 2, 2025
a8760bf
Move TsState visualization utils
Lipen Jul 2, 2025
553a67a
Remove commented code
Lipen Jul 2, 2025
176cac1
Handle fake object *inside* neqNull check
Lipen Jul 2, 2025
db104d2
Show 5 lines from stacktrace
Lipen Jul 2, 2025
3b665e6
Extract ref from fake object recursively
Lipen Jul 2, 2025
041339e
Kill the state on non-ref instance field access
Lipen Jul 2, 2025
274e11a
Fix tests
CaelmBleidd Jul 3, 2025
bd9f8bf
Remove redundant change
CaelmBleidd Jul 3, 2025
243149b
Fix issue with fake type in path constraints
CaelmBleidd Jul 3, 2025
853a615
Use y
Lipen Jul 3, 2025
090172b
Format tests
Lipen Jul 3, 2025
0e3fe6b
Use '!in'
Lipen Jul 3, 2025
f196a98
Suppress warning about deprecated `Runtime.exec`
Lipen Jul 3, 2025
e971786
Fix suppression
Lipen Jul 3, 2025
8500b63
Refactor UHeapRef.extractRefIfRequired to simplify fake object handling
CaelmBleidd Jul 3, 2025
262d245
TODO in cast expressions
CaelmBleidd Jul 3, 2025
aed737b
Cleanup
CaelmBleidd Jul 3, 2025
1299224
Fix matchers
CaelmBleidd Jul 3, 2025
d6dca5d
Fix matchers
CaelmBleidd Jul 3, 2025
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
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ object Versions {
const val clikt = "5.0.0"
const val detekt = "1.23.7"
const val ini4j = "0.5.4"
const val jacodb = "4ff7243d3a"
const val jacodb = "5889d3c784"
const val juliet = "1.3.2"
const val junit = "5.9.3"
const val kotlin = "2.1.0"
38 changes: 37 additions & 1 deletion usvm-ts/src/main/kotlin/org/usvm/machine/TsContext.kt
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@
import org.jacodb.ets.model.EtsAnyType
import org.jacodb.ets.model.EtsArrayType
import org.jacodb.ets.model.EtsBooleanType
import org.jacodb.ets.model.EtsEnumValueType
import org.jacodb.ets.model.EtsGenericType
import org.jacodb.ets.model.EtsNullType
import org.jacodb.ets.model.EtsNumberType
import org.jacodb.ets.model.EtsRefType
@@ -29,10 +31,12 @@
import org.usvm.api.typeStreamOf
import org.usvm.collection.field.UFieldLValue
import org.usvm.isTrue
import org.usvm.machine.Constants.Companion.MAGIC_OFFSET
import org.usvm.machine.expr.TsUndefinedSort
import org.usvm.machine.expr.TsUnresolvedSort
import org.usvm.machine.expr.TsVoidSort
import org.usvm.machine.expr.TsVoidValue
import org.usvm.machine.expr.tctx
import org.usvm.machine.interpreter.TsStepScope
import org.usvm.machine.types.EtsFakeType
import org.usvm.memory.UReadOnlyMemory
@@ -76,6 +80,16 @@
is EtsAnyType -> unresolvedSort
is EtsUnknownType -> unresolvedSort
is EtsAliasType -> typeToSort(type.originalType)
is EtsEnumValueType -> unresolvedSort

is EtsGenericType -> {
if (type.constraint == null && type.defaultType == null) {
unresolvedSort
} else {
TODO("Not yet implemented")
}
}

else -> TODO("${type::class.simpleName} is not yet supported: $type")
}

@@ -152,6 +166,22 @@
}
}

fun UHeapRef.unwrapRef(scope: TsStepScope): UHeapRef {
if (isFakeObject()) {
return extractRef(scope)
}
return this
}

fun UHeapRef.unwrapRefWithPathConstraint(scope: TsStepScope): UHeapRef = with(tctx) {
if ([email protected]()) {
scope.assert(getFakeType(scope).refTypeExpr)
extractRef(scope)
} else {
asExpr(addressSort)
}
}

fun createFakeObjectRef(): UConcreteHeapRef {
val address = mkAddressCounter().freshAllocatedAddress() + MAGIC_OFFSET
return mkConcreteHeapRef(address)
@@ -235,7 +265,13 @@
}
}

const val MAGIC_OFFSET = 1000000
class Constants {
companion object {
const val STATIC_METHODS_FORK_LIMIT = 5
const val MAGIC_OFFSET = 1000000

Check warning

Code scanning / detekt

Report missing or invalid underscores in base 10 numbers. Numeric literals should be underscore separated to increase readability. Warning

This number should be separated by underscores in order to increase readability.
}
}

Check warning

Code scanning / detekt

The class declaration is unnecessary because it only contains utility functions. An object declaration should be used instead. Warning

The class Constants only contains utility functions. Consider defining it as an object.


enum class IntermediateLValueField {
BOOL, FP, REF
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ interface TsInterpreterObserver : UInterpreterObserver {

fun onCallWithUnresolvedArguments(
simpleValueResolver: TsSimpleValueResolver,
stmt: EtsCallExpr,
expr: EtsCallExpr,
scope: TsStepScope,
) {
// default empty implementation
34 changes: 26 additions & 8 deletions usvm-ts/src/main/kotlin/org/usvm/machine/TsMachine.kt
Original file line number Diff line number Diff line change
@@ -26,7 +26,9 @@ import org.usvm.statistics.collectors.TargetsReachedStatesCollector
import org.usvm.statistics.constraints.SoftConstraintsObserver
import org.usvm.statistics.distances.CfgStatisticsImpl
import org.usvm.statistics.distances.PlainCallGraphStatistics
import org.usvm.stopstrategies.StopStrategy
import org.usvm.stopstrategies.createStopStrategy
import org.usvm.util.TsStateVisualizer
import org.usvm.util.humanReadableSignature
import kotlin.time.Duration.Companion.seconds

@@ -95,20 +97,36 @@ class TsMachine(
val observers = mutableListOf<UMachineObserver<TsState>>(coverageStatistics)
observers.add(statesCollector)

if (tsOptions.enableVisualization) {
observers += TsStateVisualizer()
}

if (options.useSoftConstraints) {
observers.add(SoftConstraintsObserver())
}

val stepsStatistics = StepsStatistics<EtsMethod, TsState>()

val stopStrategy = createStopStrategy(
options,
targets,
timeStatisticsFactory = { timeStatistics },
stepsStatisticsFactory = { stepsStatistics },
coverageStatisticsFactory = { coverageStatistics },
getCollectedStatesCount = { statesCollector.collectedStates.size }
)
val stopStrategy = object : StopStrategy {
val strategy = createStopStrategy(
options,
targets,
timeStatisticsFactory = { timeStatistics },
stepsStatisticsFactory = { stepsStatistics },
coverageStatisticsFactory = { coverageStatistics },
getCollectedStatesCount = { statesCollector.collectedStates.size },
)

override fun shouldStop(): Boolean {
val result = strategy.shouldStop()

if (result) {
logger.warn { "Stop strategy finished execution: ${strategy.stopReason()}" }
}

return result
}
}

observers.add(timeStatistics)
observers.add(stepsStatistics)
1 change: 1 addition & 0 deletions usvm-ts/src/main/kotlin/org/usvm/machine/TsOptions.kt
Original file line number Diff line number Diff line change
@@ -2,4 +2,5 @@ package org.usvm.machine

data class TsOptions(
val interproceduralAnalysis: Boolean = true,
val enableVisualization: Boolean = false,
)
Loading