Skip to content

Emit SMT object properties in deterministic order#9119

Open
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:fix/smt2-incremental-deterministic-object-order
Open

Emit SMT object properties in deterministic order#9119
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:fix/smt2-incremental-deterministic-object-order

Conversation

@tautschnig

Copy link
Copy Markdown
Collaborator

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.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

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 tautschnig self-assigned this Jul 17, 2026
Copilot AI review requested due to automatic review settings July 17, 2026 14:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_map entries by object unique_id before 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

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.77%. Comparing base (f5bf9cc) to head (bf92304).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants