Skip to content

Fix control flow reconstruction IndexErrors - #148

Open
Quinntyx wants to merge 2 commits into
syssec-utd:devfrom
Quinntyx:dev-decompiler_fixes
Open

Fix control flow reconstruction IndexErrors#148
Quinntyx wants to merge 2 commits into
syssec-utd:devfrom
Quinntyx:dev-decompiler_fixes

Conversation

@Quinntyx

@Quinntyx Quinntyx commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Currently, the cft layer indexes source_lines using 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_results can be longer than ordered_bytecodes, so the equivalence check and reconstruction indexes fell out of sync. The indexing between the two is now reconciled.

…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 Quinntyx changed the title Fix control flow reconstruction indexing errors Fix control flow reconstruction IndexErrors Aug 3, 2026
@Quinntyx
Quinntyx marked this pull request as ready for review August 3, 2026 16:18
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.

1 participant