Fix control flow reconstruction IndexErrors - #148
Open
Quinntyx wants to merge 2 commits into
Open
Conversation
…ytecodes equivalence_results can be longer than ordered_bytecodes when compare_pyc yields 'Extra bytecode' (bc_a is None) or 'Missing bytecode' (bc_b is None) entries. Three methods assumed direct index alignment, causing IndexError crashes: - correct_failures: build failed list by counting non-None bc_a entries instead of enumerate(equivalence_results) - purge_comp_errors: map ordered_bytecodes indices via new eq_idx_for_bc() helper before indexing equivalence_results - correct_segmentation: same fix via eq_idx_for_bc()
…ction The cft layer indexes source_lines using segmentation 'B' boundary entities, but the LLM can produce fewer source lines than there are boundaries. Pad with empty strings to cover the gap.
Quinntyx
marked this pull request as ready for review
August 3, 2026 16:18
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.
Currently, the
cftlayer indexessource_linesusing segmentation 'B' boundary entities, but the statement model is not guaranteed to return the same number of source lines as boundaries. This causes misalignment leading to Different Control Flow errors and occasionally IndexErrors.This PR fixes two indexing errors in the decompiler's control flow reconstruction that surface when the model produces fewer lines than expected by adding padding strings. This stops IndexErrors in the decompiler but doesn't actually solve misalignment--there's an implicit assumption that as long as the decompiler doesn't crash, issues like this can be caught by the perfect decompilation retrying system, which in my testing was mostly true but may be something to look at later if we're trying to chase down Different Control Flow issues.
Separately,
equivalence_resultscan be longer thanordered_bytecodes, so the equivalence check and reconstruction indexes fell out of sync. The indexing between the two is now reconciled.