Repository navigation
goto-symex: decide more pointer comparisons from value sets - #9633
Draft
tautschnig wants to merge 1 commit into
Draft
tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
try_evaluate_pointer_comparison decides `p == q`, for a pointer symbol p, from p's value set when q is an address. It gave up in two cases that are common with arrays: - q was the address of an array element other than the first: the simplifier writes &a[i] as &a[0] + i, which is not an address_of expression. Pointer arithmetic with constants on an address is now accepted. - An entry of p's value set had an unknown offset. Value sets keep one offset per object, so a pointer that is one of two elements of an array has an unknown offset. Whatever that offset, a pointer into another object than q's (or than NULL) cannot equal q: pointer arithmetic only changes the offset part of a pointer. For example, a pointer that is one of &fp[0] and &fp[1] compared with &bp[0], &bp[1] or NULL: symbolic execution kept all three branches and now prunes them (regression/cbmc/pointer-comparison-value-set, unit tests). Comparisons with addresses in the same object as an entry with unknown offset (here &fp[2]) are still left to the solver. Measurements (one run at a time): - A pointer that is one of two elements of an array, compared with each of 64 elements of another array and of its own, each branch calling a small function: 6557 -> 3485 steps, 1.68 s -> 0.83 s. - scripts/profile_cbmc.py --auto-large --runs 3: the same steps on all ten benchmarks; the pre-solver times of the two builds differed by -28 % to +68 % across runs in both orders on a host shared with other jobs (load 7 to 23), i.e. no difference is measurable there. regression/cbmc/pointer-comparison-value-set/test.desc fails on develop. regression/cbmc (also with --paths lifo), cbmc-concurrency, cbmc-cpp, cbmc-cover, cbmc-shadow-memory and cbmc-primitives pass with --validate-goto-model --validate-ssa-equation; cbmc-library's mmap/test, mmap/test_02 and munmap/test fail with these options, as on develop. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
This branch has not been deployed
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.
try_evaluate_pointer_comparison decides
p == q, for a pointer symbol p, from p's value set when q is an address. It gave up in two cases that are common with arrays:For example, a pointer that is one of &fp[0] and &fp[1] compared with &bp[0], &bp[1] or NULL: symbolic execution kept all three branches and now prunes them (regression/cbmc/pointer-comparison-value-set, unit tests). Comparisons with addresses in the same object as an entry with unknown offset (here &fp[2]) are still left to the solver.
Measurements (one run at a time):
regression/cbmc/pointer-comparison-value-set/test.desc fails on develop. regression/cbmc (also with --paths lifo), cbmc-concurrency, cbmc-cpp, cbmc-cover, cbmc-shadow-memory and cbmc-primitives pass with --validate-goto-model --validate-ssa-equation; cbmc-library's mmap/test, mmap/test_02 and munmap/test fail with these options, as on develop.