Repository navigation
[AUTOMATED] Hold the per-function budget inside the jump-table value walk and make basic-block appends linear - #1671
Merged
Conversation
CircleRange::set_nz_mask shifted its 32-bit step by the mask's lowest set bit. A RISC-V bit test (slli a1,a0,0x23; bltz a1) gives the mask 0xfffffff800000000, so the shift was 35: a debug build panicked in jump-table guard analysis and a release build used the stride 8. Such a mask now forms no range and the guard keeps the range it pulled back. Fixes Noelo-Lab#1661
When decomp_dbg panicked and left no C, kuna decompile printed "no C output" and the first 2000 characters of the transcript, which are option echoes. It now prints the panic's location and message. Refs Noelo-Lab#1661
A Go binary whose pcHeader magic has been overwritten lost every function name: no magic-based route found the table, so a go1.26 hello-world listed 198 sub_* functions instead of 1,939 and had no main.main. When no magic matches a table the image names, the pclntab pass now finds runtime.firstmoduledata by its shape and reads the table from that record alone (name table, functab, _func base, function count, text base). A record is accepted only when its slices and PC bounds agree and the functab bears them out: its first entry is minpc and its closing entry is maxpc. That test also selects the functab entry shape (go1.18+ offsets, go1.16/1.17 pointers); the go1.5-go1.15 record is read too. Section names and kinds are not used, so a renamed .gopclntab and a PE work, and PE Go detection counts such a table. locate_header still returns the header address, which the Go type harvest anchors on. The search runs only after every magic-based route has failed, on Go images only, so it ships with no option. Fixes Noelo-Lab#1638
… the per-function budget Two places ran past --max-fn-seconds in a serial decompile, with no probe of the deadline inside them: - Building a basic block renumbered the whole block once per ~280 appended operations, so a straight-line block of 30,000 instructions spent minutes in FlowInfo::split_basic. An append now steps by the smaller of the fixed gap and the order space divided by the block's operation count, so the renumbers of a block grow with the logarithm of its length. Blocks of up to 256 operations get the orders they got before. - The loops over a switch variable's values inside jump-table recovery (proving a byte map's domain, building and checking the address table) were probed only after each model. Every such loop advances through JumpValues::next, which now fails the walk once the budget is spent and names it as the site. The hang reported in the issue itself did not reproduce: both tables of the described dispatch recover in well under a second. Refs Noelo-Lab#1157
When the values of a selector's byte map cannot be proven (the index takes more values than are emulated, or the map is not read-only), the selector kept its whole 256-value range and the table was read through the map: map bytes became branch targets. The table now ends at the first selector value whose row would be read from the bytes the map occupies. Only the map's addresses are used, not its values. Fixes Noelo-Lab#1669
…r more bytes Funcdata::find_subpiece_shadow shifted a constant's 64-bit offset right by least_byte * 8. For a 16-byte constant tested at byte offset 8 that is a shift by 64: a panic in a build with overflow checks, a wrapped shift count otherwise. _dl_relocate_object in the mcount_x86_64 fixture failed to decompile in a dev build because of it. A constant wider than 8 bytes holds zero above bit 63, so the truncation now reads 0 there. Shifts below 64 are unchanged. Fixes Noelo-Lab#1674
The panic line is `<location> <message>` (the trailing colon is trimmed), as the unit test and the CLI error show. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…d profile The gh1674 stage test only fails without the fix in a build with overflow checks: a release build wraps the shift count, and for the constant 0 the wrapped shift reads the same 0. The unit test calls varnode_partial_copy_shadow on 16-byte constants directly, so it fails on the unfixed code under the test profile (the overflow panic) and also with a wrapping shift (an 8-byte piece at offset 8 of the 16-byte constant 0x1234 is not 0x1234). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
gcc does not emit two-stage tables; the 70,000-entry example is the hand-written selector_domain.S fixture, laid out the way MSVC places its table before its byte map. Also state what still reads as rows: a map before the table, another switch's map after it, or padding between. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…ves unchanged u32::MAX / 256 is 0xFFFFFF, one below the fixed 0x1000000 gap, so the append that makes a block 256 ops long already takes the shrunken gap: blocks of up to 255 ops keep their old orders. Doc and spec only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Contributor
|
[AUTOMATED] Pushed 3bb1ef2, which changes only docs. |
…ts image The replaced writable-map test only checked that the table ends at the map, which a value-narrowed writable map would also pass. With the map's last selector byte changed from 2 to 1, a read-only map narrows to two rows, while a writable one keeps all three and ends at the map. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h # Conflicts: # decompiler/crates/kuna-base/src/xml.rs # docs/baseline-stages.json
Main (Noelo-Lab#1701) split recover_go_table into recover_go_header, which the pass now calls directly; the moduledata fallback for a wiped magic moves into recover_go_header so both callers keep it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h # Conflicts: # decompiler/crates/kuna-base/src/xml.rs # docs/baseline-stages.json
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h # Conflicts: # decompiler/crates/kuna-base/src/xml.rs # docs/baseline-stages.json
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h # Conflicts: # docs/baseline-stages.json
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h # Conflicts: # decompiler/crates/kuna-base/src/xml.rs # docs/baseline-stages.json
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
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
A serial
kuna decompilecan run far past--max-fn-seconds. A 60 KB straight-line function with a 5 s budget takes about three minutes before it reports the budget:With this change the same command stops after 6 s, in
action deadcode. A two-stage jump table with a long read-only byte map had the same shape of problem: a 1 s budget ran 47 s inside the basic model of a 16M-row table (--option jumptablemax 20000000), and now stops in 1.9 s.Fix
JumpValues::next, which now fails the walk once the budget is spent and namesjump-table value walkas the site. Before, the deadline was read only after each model.reliablemode both time out) #1157 itself did not reproduce: hand-assembled PE variants of the described dispatch (two byte-indexed tables, self-recursive, tables inside the function, a 34 MB image at0x180000000) all decompile in under a second. These are the two places found where one function can still outrun its budget.Tests
bb_append_past_order_space_renumbers_rarelynow appends 200,000 operations and allows 16 renumbers (it allowed 100 for 20,000; the old code needs about 700).a_long_table_walk_stops_at_the_budget(fails without the fix: the error namesjump-table basic modelafter the whole walk) and a unit test on both value iterators.decompile-alloutput oflibz.so.1andxzis byte-identical, same speed.Refs #1157