Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e860b00
Model Pattern.compile(c).matcher(s).matches() on a symbolic string
nils-loose Nov 17, 2026
0f034ad
Executor: exact Arrays.equals/hashCode, Objects.hash, StringBuilder.e…
nils-loose Nov 17, 2026
924c5b5
Executor: lambdas with captured arguments
nils-loose Nov 17, 2026
45c8014
Merge branch 'feat/pattern-matcher-matches' into svcomp27/candidate
nils-loose Nov 17, 2026
3b62bec
Merge branch 'feat/lambda-captured-args' into svcomp27/candidate
nils-loose Nov 17, 2026
fca78d6
Merge branch 'feat/arrays-helper-models' into svcomp27/candidate
nils-loose Nov 17, 2026
d372662
Pin WitnessCreator v1.1.1 (NaN results encoded as \result != \result)
nils-loose Nov 17, 2026
93eb394
compile-target.sh: fall back to --release 8 when javac fails
nils-loose Nov 17, 2026
e6e1d61
Executor: exact model of hash containers with symbolic keys
nils-loose Nov 17, 2026
21883ca
Executor: ConcurrentHashMap in the container models; more hash controls
nils-loose Nov 17, 2026
2a3049d
Executor: unit tests for the hash container model
nils-loose Nov 17, 2026
e532847
Executor: key-set copies, list equals, and fewer needless context losses
nils-loose Nov 17, 2026
df09b44
Executor: mark String and boxed shadows that differ from the fetched …
nils-loose Nov 17, 2026
0a08619
Executor: boxed Character, Short, Byte and Boolean from int-typed arg…
nils-loose Nov 17, 2026
a0e520e
swat-benchmarks: a control for hash keys with an unknown shadow value
nils-loose Nov 17, 2026
4041ef1
swat-benchmarks: identity of the values hash container calls return
nils-loose Nov 17, 2026
ff77c06
Explorer: only real traversals forgive a given-up branch
nils-loose Nov 17, 2026
6e0db37
Merge branch 'fix/given-up-self-coverage' into svcomp27/candidate
nils-loose Nov 17, 2026
a143149
Tests and sa-soundness reproducers for given-up self-coverage
nils-loose Nov 17, 2026
0869ad7
Docs: results of the hash container model
nils-loose Nov 17, 2026
991eb1a
Merge branch 'feat/hash-container-model' into svcomp27/candidate-hash
nils-loose Nov 17, 2026
71e991b
Merge branch 'fix/given-up-self-coverage' into svcomp27/candidate-hash
nils-loose Nov 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
53 changes: 53 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,59 @@ cfg-extraction (see loop facts above).
in the entry method hashes as before. Lambdas still stop all states (`invokedynamic`), threads
are still excluded. swat-benchmarks `loop-frames` (RESULTS.md, "Loop-state matching across
frames").
- **Hash containers with symbolic keys** (since 2026-11-17, executor `CollectionInvocation.hashCall`,
`HashEntries`): a HashMap, LinkedHashMap, ConcurrentHashMap (modelled like a HashMap since then,
also with concrete keys), HashSet or LinkedHashSet that SWAT saw created keeps
its exact entries (key shadows in insertion order, value shadows). A call by key (get,
getOrDefault, containsKey, put, putIfAbsent, remove, the copy constructors, putAll; add, contains,
remove, addAll on sets; size, isEmpty, clear) with String, Integer, Long, Short, Byte, Character,
Boolean or null keys is recorded as the equality chain `key.equals(k_j)` over the stored keys:
library branches like those of the String models (`checkAndSetLibraryBranch`, masked in the SA
walk), so the path fixes which entry matched and the solver reaches the others. Before, any
symbolic key was a context loss.
- **Anything else gives the record up** (`CollectionInvocation.forget`): a call outside the
tables, a key of another class (Double, Float, classes with their own equals), a call that
ran application code or threw, the container or a view of it passed to code that is not
modelled, a change through a view or an iterator, more than 64 entries. With a symbolic key
in the container that is a context loss, as is every later call by key.
- **Iteration order:** a plain hash container iterates by hash code, which is not modelled: with
two or more entries and a symbolic key stored since it was last cleared, `next()` and
`toArray` are a context loss (sizes and `hasNext` are exact). A list copied from one is marked
(`ContainerContents.hashOrdered`): reading an element of it by position is the context loss,
its size is not. Linked containers iterate in the recorded order.
- **Checked against the JVM:** what the record says a call returns is compared with what it
returned (`checkPrimitive`, `resolveExact`); a difference gives the record up, with context
loss if a symbolic comparison was involved.
- **Only keys whose shadow value is known** (`ObjectValue.valueUnknown`): a String or boxed
shadow made by NEW has a default value until a constructor model sets it. Comparing a shadow
left at its default put `c == 0` on the path instead of `c == 'a'` (a false SAFE in
`hash-char-literal_false` before the check). `GETVALUE_Object` also marks a String or boxed
shadow whose value differs from the object it is fetched for.
- **Boxed constants** (fixed with this, 2026-11-17): the models of `Character/Short/Byte/Boolean.<init>`
took only a shadow of their own primitive type, but a constant or an int-typed expression is
passed as an int (BIPUSH, ICONST): the box kept the default 0 or false, whatever the object
held (`Boolean flag = true` read back as false, a context loss at the first unboxing, e.g.
in KeywordSearchJobSettings). They now convert as I2C, I2S and I2B do.
- **Empty immutable containers** (`Collections.emptyMap/emptySet/emptyList`): get, containsKey,
containsValue and contains return null or false whatever the argument is, so they are no
context loss either.
- **Lists with exactly known elements** (built by appending, `ContainerContents.exactOrdered`):
`equals` of two of them (ArrayList, LinkedList, Vector, Stack; also through `Objects.equals`) is
false for different sizes, else the same kind of chain over the element pairs up to the
first that differ (`CollectionInvocation.listEquals`); a HashSet can be built from one, and
from a map's key set. Any call on the list that is not modelled ends that.
- **SWAT's own helpers do not end a record:** the reference comparison `map == null` is rewritten
to `RefIdentity.same`, which is passed the container; neither it nor the ignored sinks
(`InvocationHandler.IGNORED_INVOCATIONS`) count as code that may change it.
- **Results** (2026-11-17, 3 GB, 1 core, 900 s): of the 124 round-2 runs that were UNKNOWN by
context loss, 33 become correct (31 SAFE, 2 VIOLATION), none wrong; 244 other runs of tasks
with hash containers keep their verdicts. Left in cluster A: MessagePdu (the arrays behind
`Arrays.asList` have no address when copied), the `_exceptionprone` runs (uncaught-exception
downgrade), PasswordSlotManager and ViewHierarchyEncoder (file I/O).
- **Tests:** swat-benchmarks `model-soundness`, `hash-*`, `hashset-*`, `emptymap-*`, `list-equals*`
(`scripts/model_soundness_hash.py`; its README lists which tasks must stay UNKNOWN), and the
executor's `HashContainerModelTest` (`./gradlew :symbolic-executor:test --tests
'de.uzl.its.value.reference.HashContainerModelTest'`).
- **Hangs**: the executor's `DeadlockWatchdog` (config `deadlockWatchdog`) ends a run whose
application threads all wait forever, and `ResourceBudget` has a wall-clock deadline (default:
the CPU limit), so a hang ends UNKNOWN instead of being killed by the harness.
Expand Down
8 changes: 7 additions & 1 deletion scripts/svcomp-package/compile-target.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ java_files=$(find "$target_directory" -name "*.java")

echo "javac -source 1.8 -target 1.8 -cp \"$classpath\" -d \"$build_directory\" $java_files"
# Compile all the found .java files
javac -source 1.8 -target 1.8 -cp "$classpath" -d "$build_directory" $java_files
if ! javac -source 1.8 -target 1.8 -cp "$classpath" -d "$build_directory" $java_files; then
# From JDK 25 on, every compilation unit imports java.lang.IO (JEP 512), which makes a
# wildcard-imported class named IO ambiguous (juliet's testcasesupport.IO: "reference to IO is
# ambiguous"). --release 8 compiles against the Java 8 API, which has no java.lang.IO.
echo "javac --release 8 -cp \"$classpath\" -d \"$build_directory\" $java_files"
javac --release 8 -cp "$classpath" -d "$build_directory" $java_files
fi
2 changes: 1 addition & 1 deletion scripts/svcomp-package/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ typing-inspection==0.4.4
typing_extensions==4.16.0
urllib3==2.8.0
uvicorn==0.54.0
witnesscreator @ git+https://github.com/SWAT-project/WitnessCreator@v1.1.0
witnesscreator @ git+https://github.com/SWAT-project/WitnessCreator@v1.1.1
z3-solver==5.3.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@
import de.uzl.its.swat.symbolic.value.primitive.numeric.floatingpoint.DoubleValue;
import de.uzl.its.swat.symbolic.value.primitive.numeric.floatingpoint.FloatValue;
import de.uzl.its.swat.symbolic.value.primitive.numeric.integral.*;
import de.uzl.its.swat.symbolic.value.reference.CapturingLambdaValue;
import de.uzl.its.swat.symbolic.value.reference.ObjectValue;
import de.uzl.its.swat.symbolic.value.reference.StringBuilderValue;
import de.uzl.its.swat.symbolic.value.reference.array.*;
import de.uzl.its.swat.symbolic.value.reference.lang.*;
import de.uzl.its.swat.symbolic.value.reference.regex.MatcherValue;
import de.uzl.its.swat.symbolic.value.reference.regex.PatternValue;
import de.uzl.its.swat.common.logging.records.InvocationEntry;
import de.uzl.its.swat.thread.ThreadHandler;

Expand Down Expand Up @@ -1431,9 +1434,24 @@ public void visitGETSTATIC(GETSTATIC inst) throws SymbolicInstructionException {
public void visitGETVALUE_Object(GETVALUE_Object<?> inst) throws SymbolicInstructionException {
try {
Value<?, ?> peek = stack.peekOperand();
if (inst.val != null && (peek instanceof StringValue || peek instanceof BoxedValue<?>)) {
// A String or boxed shadow whose value is not the object's is no key the exact
// model of hash containers compares (see HashEntries.supported)
boolean same = peek instanceof StringValue string
? inst.val instanceof String s && s.equals(string.concrete)
: ((BoxedValue<?>) peek).getVal() != null && inst.val.equals(((BoxedValue<?>) peek).getVal().concrete);
if (!same) {
((ObjectValue<?, ?>) peek).valueUnknown = true;
}
}
Value<?, ?> tmp;
boolean isSymbolic = false;

if (peek instanceof CapturingLambdaValue lambda && lambda.className == null && inst.val != null) {
// Created by INVOKEDYNAMIC before the JVM named the generated class
lambda.className = Util.formatClassName(inst.val.getClass().getName());
}

if (peek == PlaceHolder.symbolicInstance) {
isSymbolic = true;
peek = PlaceHolder.instance;
Expand Down Expand Up @@ -1461,6 +1479,12 @@ public void visitGETVALUE_Object(GETVALUE_Object<?> inst) throws SymbolicInstruc
stack.popOperand();
// try to get object
tmp = stack.getFromHeap(inst.address);
if ((tmp instanceof PatternValue pv && !pv.shadows(inst.val))
|| (tmp instanceof MatcherValue mv && !mv.shadows(inst.val))) {
// A different object with the same identity hash: the regex shadows hold
// exact concrete state, never reuse one for another object.
tmp = null;
}
// check if the object was created earlier and then reuse it
if (tmp != null) {
if (isSymbolic) {
Expand Down Expand Up @@ -1536,6 +1560,9 @@ public void visitGETVALUE_Object(GETVALUE_Object<?> inst) throws SymbolicInstruc
}

} else {
if (peek instanceof MatcherValue mv) {
mv.bind(inst.val);
}
(peek.asObjectValue()).setAddress(inst.address);
stack.putToHeap(inst.address, peek);
}
Expand Down Expand Up @@ -2501,7 +2528,7 @@ private boolean recordCallBranches(long iid, String name, List<StringCallBranche
* contents or the arguments are symbolic.
* </ul>
*/
private void callRunsApplicationCode(String name, String desc) throws NoThreadContextException {
private void callRunsApplicationCode(String owner, String name, String desc, long invokeId) throws NoThreadContextException {
ObjectValue<?, ?> instance;
Value<?, ?>[] arguments;
try {
Expand All @@ -2510,6 +2537,20 @@ private void callRunsApplicationCode(String name, String desc) throws NoThreadCo
} catch (Exception e) {
return; // the callee is instrumented code with its own frame
}
if (instance != null && CollectionInvocation.isContainer(instance)) {
// No model is applied: the exact entries of a hash container are not known any more
CollectionInvocation.escaped(instance, owner, name, desc, invokeId);
}
boolean containerArgument = false;
for (Value<?, ?> argument : arguments) {
containerArgument |= argument instanceof ObjectValue<?, ?> ov && ov.getContents() != null;
}
if (containerArgument && !Util.shouldInstrument(Util.formatClassName(owner))) {
// Maybe a library method that calls back: it may change the containers it is given
for (Value<?, ?> argument : arguments) {
CollectionInvocation.escaped(argument, owner, name, desc, invokeId);
}
}
if (instance instanceof de.uzl.its.swat.symbolic.value.reference.StringBuilderValue sbv) {
if (sbv.unmodelledChange(name)) {
logger.warn("StringBuilder.{} ran application code: its chars are not tracked, causes context loss", name);
Expand Down Expand Up @@ -2545,6 +2586,8 @@ private void recordThrowingInstanceCall(long iid, String owner, String name, Str
ObjectValue<?, ?> instance = stack.getInstance();
Value<?, ?>[] arguments = stack.fetchArgumentsFromLocals(Type.getArgumentTypes(desc), true);
explained = recordStringCallBranches(iid, name, desc, instance, arguments, false);
// A container call that threw is not modelled: its exact entries are given up
CollectionInvocation.escaped(instance, owner, name, desc, invokeId);
} catch (Exception e) {
explained = false;
}
Expand All @@ -2570,7 +2613,11 @@ private void recordThrowingCall(long iid, String owner, String name, String desc
try {
Value<?, ?>[] arguments = stack.fetchArgumentsFromLocals(Type.getArgumentTypes(desc), isInstance);
symbolic = isInstance && stack.getInstance().isSymbolic();
for (Value<?, ?> argument : arguments) symbolic = symbolic || argument.isSymbolic();
for (Value<?, ?> argument : arguments) {
symbolic = symbolic || argument.isSymbolic();
// The call may have changed a container it was given before it threw
CollectionInvocation.escaped(argument, owner, name, desc, invokeId);
}
} catch (Exception e) {
symbolic = true; // cannot tell, so assume the worst
}
Expand Down Expand Up @@ -2607,12 +2654,13 @@ public void visitINVOKEINTERFACE(INVOKEINTERFACE inst) throws SymbolicInstructio
new ArrayList<>(Arrays.asList(arguments)),
true,
instance);
recordCallBranches(inst.iid, inst.name, CollectionInvocation.takeBranches(), true);
stack.setReturnValue(retVal);

} else if (stack.getNextInst() instanceof INVOKEMETHOD_EXCEPTION) {
recordThrowingInstanceCall(inst.iid, inst.owner, inst.name, inst.desc, inst.invokeId);
} else {
callRunsApplicationCode(inst.name, inst.desc);
callRunsApplicationCode(inst.owner, inst.name, inst.desc, inst.invokeId);
}

if (!inst.owner.equals("de/uzl/its/swat/Main")) {
Expand Down Expand Up @@ -2647,11 +2695,12 @@ public void visitINVOKESPECIAL(INVOKESPECIAL inst) throws SymbolicInstructionExc
new ArrayList<>(Arrays.asList(arguments)),
true,
instance);
recordCallBranches(inst.iid, inst.name, CollectionInvocation.takeBranches(), true);
stack.setReturnValue(retVal);
} else if (stack.getNextInst() instanceof INVOKEMETHOD_EXCEPTION) {
recordThrowingInstanceCall(inst.iid, inst.owner, inst.name, inst.desc, inst.invokeId);
} else {
callRunsApplicationCode(inst.name, inst.desc);
callRunsApplicationCode(inst.owner, inst.name, inst.desc, inst.invokeId);
}

if (!inst.owner.equals("de/uzl/its/swat/Main")) {
Expand Down Expand Up @@ -2685,6 +2734,7 @@ public void visitINVOKESTATIC(INVOKESTATIC inst) throws SymbolicInstructionExcep
new ArrayList<>(Arrays.asList(arguments)),
false,
null);
recordCallBranches(inst.iid, inst.name, CollectionInvocation.takeBranches(), true);
stack.setReturnValue(retVal);
} else if (stack.getNextInst() instanceof INVOKEMETHOD_EXCEPTION) {
recordThrowingStaticCall(inst.iid, inst.owner, inst.name, inst.desc, inst.invokeId);
Expand Down Expand Up @@ -2771,11 +2821,12 @@ public void visitINVOKEVIRTUAL(INVOKEVIRTUAL inst) throws SymbolicInstructionExc
new ArrayList<>(Arrays.asList(arguments)),
true,
instance);
recordCallBranches(inst.iid, inst.name, CollectionInvocation.takeBranches(), true);
stack.setReturnValue(retVal);
} else if (stack.getNextInst() instanceof INVOKEMETHOD_EXCEPTION) {
recordThrowingInstanceCall(inst.iid, inst.owner, inst.name, inst.desc, inst.invokeId);
} else {
callRunsApplicationCode(inst.name, inst.desc);
callRunsApplicationCode(inst.owner, inst.name, inst.desc, inst.invokeId);
}

if (!inst.owner.equals("de/uzl/its/swat/Main")) {
Expand All @@ -2799,16 +2850,29 @@ public void visitINVOKEDYNAMIC(INVOKEDYNAMIC inst) throws SymbolicInstructionExc

if (stack.getNextInst() instanceof INVOKEMETHOD_END) {
Value<?, ?>[] arguments = stack.fetchArgumentsFromLocals(Type.getArgumentTypes(inst.desc), false);
Value<?, ?> retVal = InvocationHandler.invoke(
symbolicTraceHandler,
inst.desc,
inst.owner,
inst.name,
inst.invokeId,
new ArrayList<>(Arrays.asList(arguments)),
false,
null);
stack.setReturnValue(retVal);
// A lambda capturing arguments for instrumented code: the capture itself only
// stores them (see CapturingLambdaValue), the body runs when the lambda is called.
CapturingLambdaValue lambda = inst.owner.equals("java/lang/invoke/LambdaMetafactory")
? CapturingLambdaValue.create(
ThreadHandler.getSolverContext(currentThread().getId()),
ValueFactory.createNumericalValue(ValueType.intValue, arguments.length).asIntValue(),
inst.name, inst.desc, inst.lambda, arguments)
: null;
if (lambda != null) {
logger.debug("[INVOKEDYNAMIC] Lambda capturing {} argument(s): {}", arguments.length, lambda);
stack.setReturnValue(lambda);
} else {
Value<?, ?> retVal = InvocationHandler.invoke(
symbolicTraceHandler,
inst.desc,
inst.owner,
inst.name,
inst.invokeId,
new ArrayList<>(Arrays.asList(arguments)),
false,
null);
stack.setReturnValue(retVal);
}
} else if (stack.getNextInst() instanceof INVOKEMETHOD_EXCEPTION) {
recordThrowingCall(inst.iid, inst.owner, inst.name, inst.desc, inst.invokeId, false);
}
Expand Down Expand Up @@ -4124,6 +4188,10 @@ private void visitGETVALUE_primitive(GETVALUE_primitive inst, ValueType type) th
} else {
stack.popOperand();
}
if (placeHolder instanceof ContainerPlaceHolder containerPlaceHolder) {
// What a hash container's exact entries say the call returned, against the JVM
CollectionInvocation.checkPrimitive(containerPlaceHolder, inst.v);
}
Value<?, ?> v = ValueFactory.createNumericalValue(type, inst.v);
if (isSymbolic) {
v.MAKE_SYMBOLIC();
Expand Down
Loading
Loading