Repository navigation
Conversation
AddressableValue.compute_offset recovered the offset by subtracting the base symbol from the address expression. A cast that changes the z3 representation (e.g. a bitvector integer to a mathematical-integer pointer) wraps the whole sum, so the subtraction either mixed sorts and crashed, or could not cancel. This affected *(long *)(get_base() + 8) as well as plain integer parameters like *(long *)(a1 + 8). - Casts that change representation now carry the offset across as a signed displacement, keeping the address expression exact. The offset is only carried when the base's own value is preserved by the cast. - Addresses computed in an integer narrower than a pointer are refused on dereference in bitvector mode, since base + offset may have wrapped at the narrow width. - Integer-to-pointer casts now extend by the integer's signedness and read the bits as an unsigned address, matching the bitvector pointer representation, so signed and unsigned pointer-width integers give the same address. Pointer-arithmetic indices use a separate pointer_index conversion that keeps their sign. - Type inference treats the result of an undeclared call used as (T *)(call() + bytes) as void *, as it already did for untyped globals.
Author
|
This is completely vibe coded. Use at your own risk. |
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.
Problem
With the default representation (bitvector integers, mathematical-integer pointers), dereferencing an address built from an integer crashed:
AddressableValue.compute_offsetrecovered the offset by subtracting the base symbol from the address expression. A cast that changes the z3 representation wraps the whole sum (BV2Int(a + 8) - a), so the subtraction mixed sorts, or could not cancel even when sorts matched. The same crash hit ordinary decompiler code such as*(long *)(a1 + 8)with an__int64parameter, and the round trip(long *)((unsigned long)p + 8)failed with "Could not remove base address".Changes
ExecutionErroron dereference instead of being silently accepted.base + offsetmay have wrapped at the narrow width, and assuming otherwise produced false "equivalent" verdicts (e.g.unsigned a; *(long *)(a + 8)vs*(long *)((unsigned long)a + 8)). Integer mode, which never models wraparound, still accepts these.(void *)-1Land(void *)0xffffffffffffffffULwere different addresses. The cast now extends by the integer's signedness and reads the bits as an unsigned address, matching the bitvector-pointer representation. Pointer-arithmetic indices use a separatepointer_indexconversion that keeps their sign (p - (-1)isp + 1).(T *)(call() + bytes)asvoid *, as it already did for untyped globals. Explicitly declared integer returns keep their width.Known limitation (unchanged)
The motivating dataset pair (
search_functionfrom demmys/desk) is equivalent in integer mode, with both negative controls (next-pointer offset 48→40,return 0LL) rejected. In bitvector mode it no longer crashes but is reported nonequivalent:resolve_to_compatible_z3_reprnever pairs a pointer symbol with an integer symbol under mixed representations, so the original'sfdis never matched to the decompiled__int64 i. That is a separate change.Testing
test_differing_break_statements_results_in_nonequivalent_phis.