Repository navigation
SMT2: fix struct_tag missing from datatype_map in cycles - #9222
Open
tautschnig wants to merge 1 commit into
Open
tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
When find_symbols_rec encounters a struct_tag whose identifier is already in recstack, it skips the recursion. However, the alias datatype_map[struct_tag_type] = datatype_map[underlying_struct] is only created after the recursion returns (outside the recstack check). If another struct whose datatype is being declared has this struct_tag as a direct component, convert_type throws std::out_of_range because the struct_tag has no datatype_map entry. Additionally, find_symbols_rec used to traverse into code (function pointer) types, recursing into their parameter and return types. Since code types are rendered as Bool in SMT-LIB, this traversal is unnecessary for datatype declarations and can cause struct datatype declarations to be emitted in the wrong order: a struct discovered through a function-pointer parameter chain gets its declare-datatypes emitted before the struct it references, producing an undefined sort reference that the solver rejects. The fix has two parts: 1. When a struct_tag is already in recstack but use_datatypes is true, eagerly create the datatype_map alias from the underlying struct (which is always registered before its components are recursed). 2. Skip find_symbols_rec traversal into code types entirely. The types referenced through function pointer signatures will be discovered independently when expressions of those types appear in the formula. The bug is triggered by Kani-generated goto binaries for Rust code that uses core::fmt::Formatter, whose type graph cycles through function pointer parameters (vtable entries). It manifests as exit status 6 (uncaught std::out_of_range) with --z3 and --cvc5 but not with --smt2 --outfile (which does not use datatypes). Fixes diffblue#9190 Co-authored-by: Kiro <[email protected]>
tautschnig
requested review from
TGWDB,
kroening,
martin-cs and
peterschrammel
as code owners
October 20, 2026 19:38
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #9222 +/- ##
===========================================
- Coverage 80.91% 80.90% -0.01%
===========================================
Files 1718 1718
Lines 190266 190266
Branches 73 73
===========================================
- Hits 153952 153936 -16
- Misses 36314 36330 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3 tasks done
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.
When find_symbols_rec encounters a struct_tag whose identifier is
already in recstack, it skips the recursion. However, the alias
datatype_map[struct_tag_type] = datatype_map[underlying_struct]
is only created after the recursion returns (outside the recstack
check). If another struct whose datatype is being declared has
this struct_tag as a direct component, convert_type throws
std::out_of_range because the struct_tag has no datatype_map entry.
Additionally, find_symbols_rec used to traverse into code (function
pointer) types, recursing into their parameter and return types.
Since code types are rendered as Bool in SMT-LIB, this traversal is
unnecessary for datatype declarations and can cause struct datatype
declarations to be emitted in the wrong order: a struct discovered
through a function-pointer parameter chain gets its declare-datatypes
emitted before the struct it references, producing an undefined sort
reference that the solver rejects.
The fix has two parts:
When a struct_tag is already in recstack but use_datatypes is true,
eagerly create the datatype_map alias from the underlying struct
(which is always registered before its components are recursed).
Skip find_symbols_rec traversal into code types entirely. The
types referenced through function pointer signatures will be
discovered independently when expressions of those types appear in
the formula.
The bug is triggered by Kani-generated goto binaries for Rust code
that uses core::fmt::Formatter, whose type graph cycles through
function pointer parameters (vtable entries). It manifests as
exit status 6 (uncaught std::out_of_range) with --z3 and --cvc5 but
not with --smt2 --outfile (which does not use datatypes).
Fixes #9190