Skip to content

[AUTOMATED] kuna decompile masks every load failure behind "(unsupported/!recognized binary)" #337

Closed

Description

@mahaloz

Found while fixing #335 (C++ anonymous namespaces aborting the load). It is the reason that bug
was undiagnosable from the kuna decompile surface.

check_errors (decompiler/crates/kuna-cli/src/decompile.rs:129-133) maps any subprocess
Could not create architecture onto one generic string, discarding the real LowlevelError
message that decomp_dbg printed:

if out.contains("Could not create architecture") {
    return Some(format!(
        "could not build an architecture for {binary} (unsupported/!recognized binary)"
    ));
}

Every other surface reports the real cause, so the four disagree on the same binary.

Repro

A 4.7 KB ELF whose .symtab names a function ::b (built from quoted-symbol assembly, no
byte-patching) reproduces a load failure with --option symbolnamerepair off:

$ kuna functions         lead.elf --option symbolnamerepair off
error: could not build an architecture for lead.elf: Non-global scope has empty name
$ kuna decompile-all     lead.elf --option symbolnamerepair off
error: could not build an architecture for lead.elf: Non-global scope has empty name
$ kuna decompile-project lead.elf --option symbolnamerepair off
error: could not build an architecture for lead.elf: Non-global scope has empty name
$ kuna decompile         lead.elf main --option symbolnamerepair off
error: could not build an architecture for lead.elf (unsupported/!recognized binary)   <-- masked

Assembly for the fixture:

	.text
	.globl	main
	.type	main, @function
main:
	xorl	%eax, %eax
	ret
	.size	main, .-main
	.globl	"::b"
	.type	"::b", @function
"::b":
	ret
	.size	"::b", .-"::b"

gcc -no-pie -nostdlib -e main -o lead.elf lead.s

Why it matters

"unsupported/!recognized binary" is an actively misleading diagnosis: it says the format is not
supported
, when the truth was a specific, fixable, named engine error about one symbol. During
#335 this cost real time — three surfaces named the root cause immediately and the fourth sent
the investigation toward loader/format support.

It is also the surface an agent is most likely to be driving, and docs/options.md's first
symptom string for symbolnamerepair (could not build an architecture for <binary>: Non-global scope has empty name) is unreachable from it, so symptom-matching cannot route an
agent to the right option.

Suggested shape

Keep the generic message only as a fallback when no more specific text is available; otherwise
pass through the LowlevelError the subprocess printed, matching the other three surfaces. Note
this is driver-tier (see docs/history.md's CLI-tier precedent): no option, no stage XML, but it
does change CLI output text, so it wants a DIV row plus Rust integration tests over the four
surfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions