Emit SMT object properties in deterministic order#9119
Open
tautschnig wants to merge 1 commit into
Open
Conversation
The incremental SMT2 decision procedure emitted size_of_object and is_dynamic_object definitions by directly iterating the object map, which is an unordered map keyed by the objects' base expressions. The emission order therefore depended on expression hash values, which vary across platforms and configurations. For example, whether plain char is signed or unsigned changes the hashes of char-typed base expressions, reordering the emitted assertions and thereby producing textually different SMT problems for semantically identical inputs. Such differences needlessly perturb solver heuristics and defeat byte-for-byte comparison of generated formulas across platforms (a milder relative of the cross-platform instability discussed in diffblue#8991). Sort the objects by their unique identifier before emitting their property definitions, so that the solver receives them in a stable order independent of hash values. The unit test that previously had to compare the sent commands as an unordered collection now requires the exact deterministic sequence. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
tautschnig
requested review from
TGWDB,
kroening and
peterschrammel
as code owners
July 17, 2026 14:41
There was a problem hiding this comment.
Pull request overview
This PR makes the SMT2 incremental decision procedure emit object property definitions (size_of_object and is_dynamic_object) in a deterministic order by sorting tracked objects by their unique_id, avoiding cross-platform instability caused by unordered_map iteration order.
Changes:
- Sort
object_mapentries by objectunique_idbefore emitting property definitions to the solver. - Update the unit test to require the exact, deterministic sequence of emitted SMT commands (instead of unordered membership).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp | Sorts tracked objects by unique_id before emitting size_of_object / is_dynamic_object definitions to ensure deterministic SMT output. |
| unit/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp | Updates expectations to assert the precise command emission order now guaranteed by the implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #9119 +/- ##
===========================================
- Coverage 80.77% 80.77% -0.01%
===========================================
Files 1712 1712
Lines 189814 189820 +6
Branches 73 73
===========================================
+ Hits 153328 153331 +3
- Misses 36486 36489 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kroening
approved these changes
Jul 17, 2026
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.
The incremental SMT2 decision procedure emitted size_of_object and is_dynamic_object definitions by directly iterating the object map, which is an unordered map keyed by the objects' base expressions. The emission order therefore depended on expression hash values, which vary across platforms and configurations. For example, whether plain char is signed or unsigned changes the hashes of char-typed base expressions, reordering the emitted assertions and thereby producing textually different SMT problems for semantically identical inputs. Such differences needlessly perturb solver heuristics and defeat byte-for-byte comparison of generated formulas across platforms (a milder relative of the cross-platform instability discussed in #8991).
Sort the objects by their unique identifier before emitting their property definitions, so that the solver receives them in a stable order independent of hash values. The unit test that previously had to compare the sent commands as an unordered collection now requires the exact deterministic sequence.