Fix IR field types: statement labels/targets are ints, not statements#41
Merged
Conversation
The following IR fields were annotated as SootStmt or str but the actual runtime values are int (sequential statement indices used as labels): - SootBlock.label: str -> int - GotoStmt.target: SootStmt -> int - IfStmt.target: SootStmt -> int - LookupSwitchStmt.lookup_values_and_targets values: SootStmt -> int - LookupSwitchStmt.default_target: SootStmt -> int - TableSwitchStmt.targets: tuple[SootStmt, ...] -> tuple[int, ...] - TableSwitchStmt.lookup_values_and_targets values: SootStmt -> int - TableSwitchStmt.default_target: SootStmt -> int Cross-referenced angr's usage to confirm these are always treated as ints: e.g. cfg_fast_soot.py does `method.block_by_label[stmt.target]` (dict lookup keyed by label) and `block.label + len(block.statements)` (arithmetic). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
Member
|
Corpus decompilation diffs can be found at angr/dec-snapshots@master...angr/pysoot_41 |
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.
Summary
Several IR fields in
sootir/are annotated asSootStmtorstrbut actually holdintvalues (sequential statement indices used as labels). This PR fixes the annotations to match reality.soot_block.pySootBlock.labelstrintsoot_statement.pyGotoStmt.targetSootStmtintsoot_statement.pyIfStmt.targetSootStmtintsoot_statement.pyLookupSwitchStmt.lookup_values_and_targetsfrozendict[int, SootStmt]frozendict[int, int]soot_statement.pyLookupSwitchStmt.default_targetSootStmtintsoot_statement.pyTableSwitchStmt.targetstuple[SootStmt, ...]tuple[int, ...]soot_statement.pyTableSwitchStmt.lookup_values_and_targetsfrozendict[int, SootStmt]frozendict[int, int]soot_statement.pyTableSwitchStmt.default_targetSootStmtintWhy
The
from_irfactory methods construct these fields fromstmt_map[ir_unit], wherestmt_mapis{u: i for i, u in enumerate(units)}— i.e. ints. Type checkers in strict mode flag the mismatch.angr's usage confirms ints are the intended semantics:
angr/analyses/cfg/cfg_fast_soot.py:block.label + len(block.statements)(arithmetic)angr/engines/soot/statements/base.py:current_method.block_by_label[instr](dict lookup keyed byblock.label)angr/engines/soot/statements/switch.py: targets passed to_get_bb_addr_from_instrTest plan
pytest tests/) still passes🤖 Generated with Claude Code