Repository navigation
Model JDK container calls and System.arraycopy; containers holding symbolic values count as symbolic - #77
Closed
nils-loose wants to merge 4 commits into
Closed
Model JDK container calls and System.arraycopy; containers holding symbolic values count as symbolic#77nils-loose wants to merge 4 commits into
nils-loose wants to merge 4 commits into
Conversation
Calls on ArrayList, LinkedList, Vector, Stack, ArrayDeque, HashMap, LinkedHashMap and Hashtable that only store or return references (add, get, put with a concrete key, iterator, entrySet, toArray, ...) are modelled: the shadow of a stored value is kept in the container's ContainerContents, and a returned element is matched to it by address once the concrete result is known (GETVALUE_Object). Views, iterators and entries share the contents of their container. Collections.singleton, enumeration, unmodifiable* and Arrays.asList are modelled the same way. A container that may hold a symbolic value now counts as symbolic, so a call that is not modelled (contains, indexOf, sort, toString, ...) still records context loss. A returned element that cannot be matched while the container may hold a symbolic value records context loss as well. ObjectValue.isSymbolic(visited) walked fields only, so a String, boxed value or primitive array held in a field never counted as symbolic; it now uses the value's own isSymbolic(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shadow elements are copied from the source array to the destination array (primitive arrays: as stores into the array formula; object arrays: the element shadows). Symbolic positions or lengths, copies longer than 4096 elements and arrays of arrays stay unmodelled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
String and boxed keys were concrete when stored and cannot change, so walking them on every modelled map call only costs time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
JDK container models (
CollectionInvocation,ContainerContents,ContainerPlaceHolder).Calls on
ArrayList,LinkedList,Vector,Stack,ArrayDeque,HashMap,LinkedHashMapandHashtablethat only move references are modelled. These are add/addLast/push/set, get/getLast/poll/remove(int), put/get/remove/containsKey with a concrete key, addAll/putAll and the copy constructors, iterator/listIterator/keySet/values/entrySet, toArray(), size/isEmpty/clear. The same goes for their views, iterators, entries and enumerations, and forCollections.singleton*/enumeration/unmodifiable*andArrays.asList.ContainerContents.GETVALUE_Object). A view or iterator shares the contents of its container.ObjectValue.isSymbolic(visited)walked fields only. As a result, a String, a boxed value or a primitive array held in a field never counted as symbolic, and an object holding one went into an unmodelled call without context loss. It now uses the value's ownisSymbolic().System.arraycopyis modelled when the positions and the length are concrete. Primitive arrays get stores into the array formula. Object arrays copy the element shadows. Longer than 4096 elements, or arrays of arrays, stay unmodelled.Measured
Setup: sv-comp.cfg, nosa, 300 s, 15 GB, against
baseline-results.jsonl.Runs: 500.
context-loss-collections,context-loss-other-jdk,jdk-container-issymbolic-ignores-elementsorworker-threads-not-tracked, plus all of securibench.java.util/Systemmissing invocation, or a correct SAFE with an object-taking missing invocation.Result: +44, -0, net +44, 0 new wrong verdicts. CPU over the 500 runs: 6615 s base, 6461 s new.
Tests
JdkContainerAgentSpec(L2,agentTest):String.joinover a list holding it all record context loss.ContainerContentsTest(L0): isSymbolic through fields and views, lookup by address, ambiguity, late addresses, keys that become symbolic.Known limits
HashSet/TreeMap/PriorityQueue,toArray(T[]),List.of,forEach/streams are not modelled.context-loss-other-jdk:identityHashCode, as the shadow heap does. A collision or ambiguity falls back to context loss.🤖 Generated with Claude Code