Repository navigation
[AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels - #897
Merged
Merged
Conversation
…, not as their labels In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW
mahaloz
added a commit
that referenced
this pull request
Oct 5, 2026
…xtents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> --------- Co-authored-by: Zion Leonahenahe Basque <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <codex@localhost> Co-authored-by: wirsbf <[email protected]> Co-authored-by: phix33 <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Oct 5, 2026
* [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> --------- Co-authored-by: Zion Leonahenahe Basque <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <codex@localhost> Co-authored-by: wirsbf <[email protected]> Co-authored-by: phix33 <[email protected]> --------- Co-authored-by: Zion Leonahenahe Basque <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <codex@localhost> Co-authored-by: wirsbf <[email protected]> Co-authored-by: phix33 <[email protected]>
mahaloz
added a commit
that referenced
this pull request
Oct 5, 2026
* [AUTOMATED] fix(p9): guard ARM register-controlled left shifts * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> --------- Co-authored-by: Zion Leonahenahe Basque <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <codex@localhost> Co-authored-by: wirsbf <[email protected]> Co-authored-by: phix33 <[email protected]> * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags (#895) * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width po…
mahaloz
added a commit
that referenced
this pull request
Oct 5, 2026
…rators (#901) * [AUTOMATED] fix(p9): preserve declared callback signatures in C declarators * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> --------- Co-authored-by: Zion Leonahenahe Basque <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <codex@localhost> Co-authored-by: wirsbf <[email protected]> Co-authored-by: phix33 <[email protected]> * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags (#895) * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack agg…
mahaloz
added a commit
that referenced
this pull request
Oct 5, 2026
…916) * [AUTOMATED] Preserve switch early returns at declared function ends Join already visited instructions at the inclusive flow boundary before decoding the final in-range instruction again. This preserves return-only switch entries and out-of-range guards sharing the final RET with the last case. Add a bounded authored switch stage and native round-trip controls for shared and separate returns, duplicate return entries, signed guards, and a genuine post-switch write. Update the lift/flow specification and stage inventory. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> --------- Co-authored-by: Zion Leonahenahe Basque <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <codex@localhost> Co-authored-by: wirsbf <[email protected]> Co-authored-by: phix33 <[email protected]> * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags (#895) * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock…
mahaloz
added a commit
that referenced
this pull request
Oct 5, 2026
* [AUTOMATED] Preserve NaN operand selection in SSE MINSS * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> --------- Co-authored-by: Zion Leonahenahe Basque <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <codex@localhost> Co-authored-by: wirsbf <[email protected]> Co-authored-by: phix33 <[email protected]> * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags (#895) * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on…
mahaloz
added a commit
that referenced
this pull request
Oct 5, 2026
…re calls (#919) * [AUTOMATED] Preserve return storage across known terminal helper calls Share flow no-return contracts with the bounded callee write probe and refresh cached summaries when those facts change. Retain conservative handling of unknown or predicated calls, incomplete bodies, return-storage writes and explicit effects. Focused validation: 2 CLI regressions (both fail unpatched), native and emitted-C oracles at -O0/-O2, 152 selected library tests, 6 catalog/freshness tests, 51 stage assertions, catalog --check and make check-spec. Broad parity and workspace suites deferred to PR CI per task instructions. * [AUTOMATED] Update Ghidra query pin for nested callee facts Account for host symbol queries needed by the callee write probe's shared no-return contract lookup. A traced lookup-disabled control restores the original fingerprint; every added query is a nested probe call target. Retain all rendered-C and instruction-query pins. Validation: complete kuna-ghidra release tests, including ignored tests; git diff --check. Full parity, integration and cargo workspace validation remain delegated to PR CI. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> --------- Co-authored-by: Zion Leonahenahe Basque <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <codex@localhost> Co-authored-by: wirsbf <[email protected]> Co-authored-by: phix33 <[email protected]> * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags (#895) * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public addre…
mahaloz
added a commit
that referenced
this pull request
Oct 5, 2026
…921) * [AUTOMATED] Propagate explicit no-return markings through wrappers * [AUTOMATED] Preserve switch defaults selected before indirect jumps Restore JumpBasic2 guard handling so its final destination is marked as switch default without rewriting the guard. Preserve guarded statements and shared case destinations. Add a self-contained native round trip covering 16 dispatch variants and 69 selectors with GCC and Clang at O0/O2. The regression fails on the base. 35 focused release tests, check-spec, and catalog checks pass. Broad parity and workspace gates are deferred to PR CI. * [AUTOMATED] Reduce workspace CI debug artifact disk usage * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> --------- Co-authored-by: Zion Leonahenahe Basque <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <codex@localhost> Co-authored-by: wirsbf <[email protected]> Co-authored-by: phix33 <[email protected]> * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags (#895) * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 b…
mahaloz
added a commit
that referenced
this pull request
Oct 5, 2026
* [AUTOMATED] Propagate explicit no-return markings through wrappers * [AUTOMATED] Preserve parameter inputs across assertion replay Carry edited parameter names and types by slot through the prototype seed, and keep parameter symbols out of local-symbol replay. Cover incoming register values, conditional overwrites, swapped names and stack parameters with generated fixtures and native semantic checks. Validation: 6 new and 20 nearby CLI tests; 26 selected stage and 6 upstream aggregate-return assertions; repeated console rebuild; check-spec and diff checks. Broad parity, workspace, tooling and lint checks deferred to final PR CI under the user testing exception. * [AUTOMATED] Reduce workspace CI debug artifact disk usage * [AUTOMATED] Keep parameter inputs separate from later register aliases Resolve parameter entries, naming and type seeds at the selected usepoint, and use linked symbol categories for declarations. Permit exact-width parameter register reuse only with proven disjoint covers. Validated focused CLI and symbol regressions, the original replay, datatest parity (675/675), stage parity (1910/1910), and spec checks. The user requested stopping the remaining local CI run and delegating workspace, tooling, lint and Ghidra checks to upstream PR CI. * [AUTOMATED] Preserve asserted local type locks during inference Apply isolated local type locks when a varnode is created at the mapped usepoint. Preserve that lock when simplification moves an output, without locking incoming values or later register reuse. Verified the reported local-type assertion regression, 28 CLI name/parameter controls, a new type-lock isolation regression, and spec checks. Broader local and upstream CI checks remain in progress. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> --------- Co-authored-by: Zion Leonahenahe Basque <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <codex@localhost> Co-authored-by: wirsbf <[email protected]> Co-authored-by: phix33 <[email protected]> * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags (#895) * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to…
mahaloz
added a commit
that referenced
this pull request
Oct 5, 2026
…926) * [AUTOMATED] Propagate explicit no-return markings through wrappers * [AUTOMATED] Keep stored integers in variadic format calls * [AUTOMATED] Reduce workspace CI debug artifact disk usage * [AUTOMATED] Rescue only rejected variadic trials and refresh catalog * [AUTOMATED] Check every variadic format byte for immutability * [AUTOMATED] Require defined prefixes for variadic argument recovery * [AUTOMATED] Bound CI workspace debug artifact size The upstream workspace runner exhausted its disk before completing tests. Match the local wrapper with line-table debug information and disabled incrementality; retain debug assertions and overflow checks. * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * [AUTOMATED] fix(analysis): recover ARM xref callers at their frame entries On stripped ARM ELF files, reference queries omitted calls from functions that no direct call reaches, or assigned them to an interior entry. Share validated ARM/Thumb frame recovery between the reference walk and the function inventory under funcstart_patterns, matching LR-saving prologues in the live decode mode and instruction byte order, including BE8 images. Carry ISA modes with control-flow edges and publish them only over successfully decoded instructions, so unrelated code keeps its mode across queries and later decompilation. Discard contradicted bodies, references and callees together, keep invalidated entries out of retries, and check pool and pointer entries before AIF bodies claim their bytes. Reuse validated bodies and context-certified decoding, and rewalk only affected callers when their original instructions remain valid. Frame probes follow the not-taken path of a conditional return; code reached through a call's fall-through is speculative and ends the probe at an invalid word or at another prologue rather than rejecting the frame or absorbing the next function. The AIF gap walk, pool, pointer and referenced-target validators keep their existing behavior, so inventories with funcstart_patterns off are unchanged. Authored Apache-2.0 ELF generators cover missing and misattributed calls, prefix replacement, stale retries, instruction interiors, pool and pointer entries, non-returning calls before literal pools, and a 384-case graph matrix checking calls, modes and unrelated C across layouts and repeated queries. Both parity suites, lint, spec, catalog, CLI, tooling and Ghidra checks pass; the workspace retains only the known pointer-type failure. Co-Authored-By: Claude Fable 5.1 <[email protected]> * [AUTOMATED] Keep clamped integers through late variadic prototype binding Preserve existing unfinalized variadic trials when resolving a locked imported prototype, then retry rejected trials once supported integer-format evidence is available. Extend the bounded byte proof through comparisons, low-byte arithmetic and register clearing; consult memory ranges independently of named-array flags. Focused release checks passed: variadic_secondary_reader (native and emitted GCC/Clang O0/O2, optimized C and PE/IAT cases with negative controls), variadic_xmm_whole, and variadic_readonly_format (eight XML expectations). Broad local CI will run before publication. * [AUTOMATED] Verify imported promoted doubles survive prototype binding An authored PE reproduces the omitted %.02f argument on the previous implementation. Preserving existing variadic trials retains the already recovered double with either varargforward setting, without extending integer-format parsing. Focused secondary-reader, XMM and readonly-format checks pass. Native and emitted GCC/Clang O0/O2 verify exact promotion bits including signed zero. Bounded project replays restore both clamped integers and the promoted double with zero rejected assertions; no live-game oracle is claimed. Full local CI runs next before publication. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> --------- Co-authored-by: Zion Leonahenahe Basque <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <codex@localhost> Co-authored-by: wirsbf <[email protected]> Co-authored-by: phix33 <[email protected]> * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags (#895) * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which retu…
mahaloz
added a commit
that referenced
this pull request
Oct 5, 2026
* [AUTOMATED] Propagate explicit no-return markings through wrappers * [AUTOMATED] Keep stored integers in variadic format calls * [AUTOMATED] Reduce workspace CI debug artifact disk usage * [AUTOMATED] Rescue only rejected variadic trials and refresh catalog * [AUTOMATED] Check every variadic format byte for immutability * [AUTOMATED] Require defined prefixes for variadic argument recovery * [AUTOMATED] Bound CI workspace debug artifact size The upstream workspace runner exhausted its disk before completing tests. Match the local wrapper with line-table debug information and disabled incrementality; retain debug assertions and overflow checks. * [AUTOMATED] Keep clamped integers through late variadic prototype binding Preserve existing unfinalized variadic trials when resolving a locked imported prototype, then retry rejected trials once supported integer-format evidence is available. Extend the bounded byte proof through comparisons, low-byte arithmetic and register clearing; consult memory ranges independently of named-array flags. Focused release checks passed: variadic_secondary_reader (native and emitted GCC/Clang O0/O2, optimized C and PE/IAT cases with negative controls), variadic_xmm_whole, and variadic_readonly_format (eight XML expectations). Broad local CI will run before publication. * [AUTOMATED] Verify imported promoted doubles survive prototype binding An authored PE reproduces the omitted %.02f argument on the previous implementation. Preserving existing variadic trials retains the already recovered double with either varargforward setting, without extending integer-format parsing. Focused secondary-reader, XMM and readonly-format checks pass. Native and emitted GCC/Clang O0/O2 verify exact promotion bits including signed zero. Bounded project replays restore both clamped integers and the promoted double with zero rejected assertions; no live-game oracle is claimed. Full local CI runs next before publication. * [AUTOMATED] Correct signed native switch case labels * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> --------- Co-authored-by: Zion Leonahenahe Basque <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <codex@localhost> Co-authored-by: wirsbf <[email protected]> Co-authored-by: phix33 <[email protected]> * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags (#895) * [AUTOMATED] fix(p2): preserve ARM CPSR control state and GE flags * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): apply the call-fixups the host attaches to a callee (#898) In Ghidra mode on Windows, kuna printed calls to the MSVC helpers stock Ghidra replaces with the compiler spec's call-fixups: `__chkstk`, `__security_check_cookie`, the x86 EH/SEH prolog helpers, and the Control Flow Guard dispatcher, so every guarded virtual call printed as `_guard_dispatch_icall(v10)` with its real target gone. Ghidra's Call-Fixup Installer tags these functions and Java sends the tag as the `<inject>` of the callee's `<prototype>`. The decoder dropped it. It now resolves the name against the cspec call-fixups (FuncProto::decode's getPayloadId) and carries the payload id to the flow's queryCall and to the global entry ActionDeindirect reads; the p-code already came from getCallFixup. The standalone CLI is unchanged. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(p9): render partial scalar joins as C arithmetic (#905) Replace a proven preserved upper prefix and rewritten lower suffix with unsigned masks and OR. Keep the full return value and truncate promoted narrow expressions to their machine width. The module 5 sweep changed only eight port conversion helpers across 880 functions. Emitted C matched assembly in 2,917,504 comparisons. All four gates, tooling tests, lint, and the catalog check passed. * [AUTOMATED] Recover one retry loop and emit while (true) (#906) * [AUTOMATED] fix(p8): preserve early continues in retry loops * [AUTOMATED] feat(p9): default infinite loops to while (true) --------- Co-authored-by: Codex <codex@localhost> * [AUTOMATED] fix(p4): a value returned in two registers came back with its halves swapped on big-endian targets and AVR (option bejoin) (#763) ## The problem Some big-endian two-register returns print with their halves swapped. For example: ```sh printf '%s\n' 'long long wide_mul(int a, int b) { return (long long)a * b; }' > wm.c clang --target=powerpc-linux-gnu -O2 -c wm.c -o wm.o kuna decompile wm.o wide_mul ``` ```c return CONCAT44(a1 * a0,(int)((unsigned long)((long)a1 * a0) >> 0x20)); ``` ## The fix - `kuna decompile wm.o wide_mul --option bejoin on` joins the returned words in ABI order. Selected call-result pairs and AVR register pairs use the same correction. - `bejoin` is off by default, including in aggressive mode. Its instruction-based heuristic can mistake a genuine 32-bit return for a 64-bit value, so enabling it remains an explicit choice. - With the option off, output follows main's existing behavior. Known limitations and the evidence needed for a safe default are recorded in #904. ## The tests Stage and compiled round-trip tests cover big-endian targets, AVR, narrow returns, and little-endian controls. Differential checks compare default output with main and enabled output with the previous implementation. Part of #904 * [AUTOMATED] Preserve late-resolved stores across memory effects (#907) ## The problem A store made between two calls disappears when the compiler reloads the global's address from a frame slot. Both calls survive, so the second call observes the wrong value. ```sh printf 'int gi;void touch(void);int s7(int b){gi=b;touch();gi=9;touch();return 1;}\n' > s7.c clang --target=aarch64-linux-gnu -O0 -c s7.c -o s7.o kuna decompile s7.o s7 ``` The emitted body contains: ```c dat_400044 = a0; touch(); touch(); ``` ## The fix - Connect a newly resolved direct store to its existing memory effects immediately, before dead-code removal. - Preserve unaffected bytes for overlapping ranges in either endianness; leave effects belonging to other operations alone. ## The tests AArch64 and x86-64 fixtures at `-O0`/`-O2` recompile and execute the printed C with callbacks that observe and change memory. They cover repeated stores, aliasing and distinct pointers, intervening loads, branches, and dead stores. Byte-level tests cover exact, partial, contained, and disjoint effects in both endiannesses. Existing expectations are unchanged; measured speed delta is at most +1.8%. References #886. * [AUTOMATED] Preserve memory effects of enabled inline syscalls (#908) ## The problem An inline system call can overwrite a global buffer, but a later read still uses its pre-call value (#856 in #890). ```sh cat >/tmp/svc.c <<'C' int sink; int rd(int fd, int x) { int v = x + 7; sink = v; register int r0 asm("r0") = fd, r1 asm("r1") = (int)&sink; register int r2 asm("r2") = 4, r7 asm("r7") = 3; asm volatile("svc 0" : "+r"(r0) : "r"(r1), "r"(r2), "r"(r7) : "memory"); return v * 5 + sink; } C clang --target=armv7-linux-gnueabi -O2 -c /tmp/svc.c -o /tmp/svc.o kuna decompile /tmp/svc.o rd --option syscallregs on ``` ```c return (a1 + 7) * 6; ``` ## The fix - Give recognized, enabled syscall user ops unknown effects on writable memory during heritage; keep the store before the call and reload afterward. - Save pointer loads before a syscall instead of moving them across it. - Reuse `syscallregs`' existing OS-image policy; unrelated user ops and `off` retain their behavior. ## The tests ARM stage off/on witness; compiled C round trips check kernel-observed stores, changed global buffers, and values saved before one or two calls. Cross-architecture side-effect probes and the full test suite pass. Default whole-loader timing (264 MIPS functions, interleaved min-of-11): −2.2%. * [AUTOMATED] Preserve writes through spilled stack pointers (#910) ## The problem At `-O0`, a write through a pointer spilled to the stack can disappear, leaving the return value equal to the array's initializer (#858, #890). ```sh cat >/tmp/spill.c <<'C' int h5(int a, int x, int y) { int s[2] = {x, y}; int *p = s; p[1] = a * 3; return s[1]; } C gcc -O0 -fno-stack-protector -c /tmp/spill.c -o /tmp/spill.o kuna decompile /tmp/spill.o h5 --assert 'prototype h5 int h5(int a, int x, int y)' ``` Current output: ```c int h5(int a,int x,int y) { return y; } ``` ## The fix - Preserve stack reads until a spilled store pointer resolves, then retain guards only for proven overlapping stack destinations. - Restrict the proof to full-width pointers on byte-addressed stacks; unknown aliases keep the existing policy. - Filter proven targets in closed large frames and bound provisional work elsewhere. Explicit broad alias guarding remains available. ## The tests Compile and execute printed C from 14 GCC/Clang objects across six architectures, covering changed elements, constants, neighbors, repeated writes, pointer reassignment and call escapes. The repro fails without this fix. Existing 675 datatest and 1,878 stage assertions retain parity; the workspace and spec checks pass. Closed 64–256-store stress runs improved 2.9–7.8%; measured O0/O2 `basename` and `cat` runs show no slowdown. * [AUTOMATED] Preserve computed global write order (#911) ## The problem A computed global update can print before an aliasing pointer load, changing a return from 904 to 909. The same merging can hoist case-local volatile stores ahead of a switch and add writes. ```sh cat >/tmp/globalorder.c <<'C' int gi=4; int ew(int *p,int b) { int t=gi*2+b; int x=*p; gi=t; return x+t*100; } int main(void) { return ew(&gi,1); } C gcc -O0 /tmp/globalorder.c -o /tmp/globalorder kuna decompile /tmp/globalorder ew ``` ```c gi = a1 + gi * 2; v1 = *a0; return v1 + gi * 100; ``` ## The fix - Keep computed values separate when merging would move a guarded global write across an observation or onto another path. - Preserve the delayed copies before forced phi merging; keep existing handling for global-state markers and old global values. - Apply this strict correction within the existing `indexaliasguard global` default. ## The tests Five stage assertions, GCC/Clang O0/O2 native roundtrips and actual memory-access traces, a marker-state IR control, and Ghidra store-order assertions. The existing 675 assertions, workspace suite, and spec checks pass; no datatest baseline moved. Eleven alternating timing pairs: fmt −3.1%, ls −3.0%, 600-update stress −0.9%. Fixes #871. * [AUTOMATED] Preserve writes to wrapped stack aggregates (#912) ## Problem A callback writing into an ARM struct parameter's stack spill is lost: the function returns the saved field value. On main, this prints the incorrect lines below: ```sh cat >/tmp/wrapped.c <<'C' struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;}; short readtemp0(struct dev d){if(d.temp)d.temp(&d,&d.t);return d.t;} C clang --target=thumbv7em-none-eabi -O0 -c /tmp/wrapped.c -o /tmp/wrapped.o kuna decompile /tmp/wrapped.o readtemp0 \ --assert 'typedef struct dev {void (*temp)(struct dev *,short *);int pad[16];short t;};' \ --assert 'prototype readtemp0 short readtemp0(struct dev d)' ``` ```c (*v1)((dev *)&v1,(short *)&Stack00000034); return SUB562(v2,0x34); ``` ## Fix - Recover one local struct when its wrapping spill exactly matches a locked register/stack parameter layout; the callback now receives `&v1` and `&v1.t`, and the function returns `v1.t`. - Preserve its two physical stack pieces through snapshots, retyping, removal, and repeated decompilation. - Give wrapped locals distinct temporary wire storage because Ghidra cannot represent a stack variable spanning entry SP=0; ordinary JOIN mappings keep their existing encoding. ## Tests Thumb/ARM big-endian O0/O2 printed-C execution checks callback writes, field pointers, register prefixes, and distinct struct types. Mapping/serialization tests cover snapshots, retyping/removal, mixed mappings, storage identity, and repeated decompilation; stock Ghidra decodes distinct storage. Parity remains 675/675 and 1883/1883; the workspace and other local checks pass. Affected fixtures: −0.9% to +1.3%; O0/O2 coreutils: −1.9% to +1.1%; a pinned 31-pair repeat of O0 cat measured +0.03%. Fixes #861. * [AUTOMATED] Fix missing and incomplete variable source comments Preserve machine homes through simplification and report all register and stack sources for locals and parameters. Add synthetic regressions and source-provenance checks. * [AUTOMATED] Preserve incoming caller stack addresses in emitted C (#915) [AUTOMATED] Preserve proven SysV AMD64 incoming caller storage in emitted C. Use a CFA expression and selective noinline declarations so native and rebuilt functions return the same caller addresses. Existing 675 datatest and 1900 stage assertions remain unchanged; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native GCC/Clang, project, typed-pointer and dynamic-stack checks pass. Matched N11 timing: fmt -0.195%, ls -0.635%, incoming -0.319%. * [AUTOMATED] Preserve partial global stores before input pointer reads (#909) [AUTOMATED] Preserve partial global stores before input pointer reads. Retain actual narrow stores when a witnessed input-derived pointer can observe them before an overwrite. Keep the original store addresses and widths. Validation: 675/675 datatest and 1900/1900 stage assertions; full Rust, CLI, spec, catalog, lint and tooling checks pass. Native round trips repair all 58 failing observations in the affected set. The 922-function control sweep is unchanged. Matched timing: affected +1.12%, global-load controls +0.51%, whole binary +0.16%. Addresses the partial-global-store entry in #890 (formerly #887). * [AUTOMATED] Preserve memory effects and result order for known syscalls (#913) [AUTOMATED] Preserve saved values, real stores and returned-length ordering across recognized syscalls. Admit x64 memory effects only in the proved GCC SysV stack domain. Fence saved loads and full result expressions against intervening memory reads for enabled recognized syscall families. Validation: 675/675 datatest assertions, 1905/1905 stage assertions with five added and none removed, full Rust, CLI, spec, catalog, lint and tooling checks pass. Native Linux pipes, caller-pointer payloads, project exports, five-family result tests and ABI boundary controls pass. The 775-function control sweep is unchanged. Matched full-loader timing: +2.12%, eleven interleaved pairs over all 299 functions. Addresses the syscall-memory entry in #890 (formerly #856), following #908. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller (#925) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. * [AUTOMATED] fix(analysis): keep distant call sites with their reachable caller Retain ARM instruction successors and assign references to entries that reach their bodies. Share that ownership with CLI call graphs, including direct callers, indirect-call flags and bounded inventory fallbacks. Add authored little- and big-endian regressions with callers established by ordinary calls. Both regressions fail before the fix. Focused tests, parity and supporting checks pass; the workspace retains its documented unrelated pointer-type failure. * fix(sleigh): the staging-window test cannot wrap at the top of the address space (#918) windowed_load_fill served a request from the 512-byte window when curaddr0 + size < bufoffset + 512. For a request at the top of the address space (a sign-extended negative pointer such as 0xffff_ffff_ffff_6818) curaddr0 + size wraps to a small value, the test passes, and the in-window offset indexes far past the buffer: decompile-all panicked on libuv 1.x built for x86-64 at -O2/-O3. Compare the in-window offset instead, which is the same test without the wrap. Unit test: a read at 0xffff_ffff_ffff_fffe after a window at 0x1000 panicked before and is now refilled. Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] Exclude call argument transport from local variable sources (#927) Omit parameter source comments and distinguish native value homes from outgoing argument shuffles. Retain write identity and meaningful local uses so late stack heritage can retract temporary reloads without losing genuine definitions. Validation: make test (675/675), make test-stages (1912/1912), make rust-test (8006 passed), make check-spec, test-cli (277/277), test-tools (42), lint, catalog, counters, and option documentation freshness. * [AUTOMATED] feat(sleigh): support isolated speculative decoding (#924) * [AUTOMATED] feat(sleigh): support isolated speculative decoding Add nested context scopes that preserve write boundaries, tracked registers and cache state, with rollback, explicit commit and probes of saved context. Certify reusable lifts only when their bytes and complete decode context suffice and they commit no context. Decoder tests and parity, CLI, Ghidra, lint, spec and catalog checks pass. The workspace retains the documented unrelated pointer-type failure. * [AUTOMATED] fix(sleigh): include read overrides in decode reuse keys Build and compare reuse keys from the effective context read by translation, including ContextCache overrides. Compare words without allocating a new key. Add a regression that switches the same bytes between ARM and Thumb through read overrides, rejects stale keys and accepts equivalent effective contexts. Both parity gates and all decoder tests pass. The full workspace retains the known unrelated pointer-argument C compilation failure. --------- Co-authored-by: wirsbf <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Zion Leonahenahe Basque <[email protected]> * [AUTOMATED] fix(p2): keep interior entries within asserted function extents (#894) * [AUTOMATED] fix(p2): keep interior entries within asserted function extents * [AUTOMATED] fix(ghidra): print the strings Ghidra defines as literals, not as their labels (#897) In Ghidra mode a string Ghidra had defined printed as its label (`s_SplitterContainer__create___Regi_1404c4098`, `u_splitterContainer_1404c4070`) where the stock decompiler prints the literal. The printer's string-literal arm checks that the address is read-only by asking the global scope, which kuna answered from its local symbol table. In Ghidra mode that table is empty and every program fact lives in the lazy remote scope, so the check said "not read-only" for every string and the reference fell back to the label. The check now goes through `Architecture::is_global_read_only`, which asks the remote scope when one is installed, as upstream's ScopeGhidra::isReadOnly does. The ghidra-sim oracle can now answer a string's address the way Java does (a read-only, type-locked character array under its label). Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(analysis): demangle the MSVC names msvc-demangler rejects (#899) msvc-demangler fails on encodings recent MSVC emits, and kuna then printed the raw symbol: on qBittorrent 5.2.4's PDB, 536 functions (932 names with aliases) such as every QStringBuilder `operator+`/`operator%`, which return a deduced `auto` (`?A_P`). A `?` name msvc-demangler rejects now falls back to `undname`, a port of LLVM's MicrosoftDemangle, which reads `auto` returns, `operator<=>`, `noexcept` function types, address and member-pointer template arguments and vtordisp thunks. Its name-only output goes through the same reduction, with LLVM's `dtor`/`ctor` phrasing spelled as msvc-demangler spells it, and a vtordisp thunk folded into one identifier (`QDtlsBasePrivate::error_vtordisp_4_0`). Names msvc-demangler accepts are untouched. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * [AUTOMATED] fix(ghidra): print C++ namespaces the way Ghidra's decompiler does (#900) In Ghidra mode kuna printed every C++ name bare: `instance()` where the native decompiler prints `UIThemeManager::instance()`, and `ArticleListWidget(...)` for the declaration of `ArticleListWidget::ArticleListWidget`. Java sends a symbol's bare name plus its namespace id; kuna resolved the path but never printed it. - Port `PrintC::pushSymbolScope`/`emitSymbolScope` and `Symbol::getResolutionDepth` over namespace name paths (p9_emit/kuna_namespaces.rs). Calls carry the scopes the Display Namespaces strategy needs from the calling function's namespace (Minimal by default), declarations their full path, one token per scope so Java renders `::` instead of `__`. - The collision test that can add a scope asks the host (`isNameUsed`) once the function's own locals are ruled out, as `ScopeLocal::isNameUsed` -> `ScopeGhidraNamespace::isNameUsed` does upstream. - The existing global-name qualifier now uses the same resolution rule. - The ghidra-sim oracle models namespaces (ids per `::` prefix and the getNamespacePath answer). qbittorrent.exe with its PDB, 100 sampled functions in real Ghidra: call names matching stock exactly 443 -> 710 of 725; the rest are string and expression differences, not namespaces. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-authored-by: Claude Opus 5.5 <[email protected]> * web(collab): add "Connect across the internet" to live sessions (#902) Live sessions at `/decompile/` only connected people on one network. The pages used no ICE servers, and the only way to add a STUN server was a `localStorage` key set from the browser console, so two people on different networks got "Could not connect directly. You may need to be on the same network." The invite dialog now has a box for it: ``` Your name [ Ana ] [ ] Connect across the internet (?) [Make an invite link] ``` Hovering or focusing the **?** says: "For people on other networks. It uses Cloudflare's STUN server, which only tells each browser its internet (IP) address so the two computers can connect. None of your data passes through it: the program and the changes go straight between the browsers. The invite link then includes your IP address." - The box starts unticked and is remembered in `kuna.d2.collab` as `stun: true`, the key the console setting already used. `stun: true` now means `stun:stun.cloudflare.com:3478` instead of Google's server; a `stun:` URL still picks another, and the TURN setting is unchanged. - The choice belongs to the session. Its later links and the introductions between members use it. A guest's page answers an invite that carries an internet address with STUN too, so guests need no setting; their join dialog says that joining shares their IP address. - A failed connection says what to try. In a session on one network, it suggests a new link with the box ticked. In a session across the internet, it suggests trying another network. If STUN finds no address, the invite says the link may work only on that network. - With the box ticked, making a link waits up to 1.5 s for STUN. Unticked, nothing changes. Tests: `decompile2-collab.mjs` covers the setting, the session's override and `crossesNetworks`. A new `decompile2-collab-page.mjs` case covers the dialog in Chrome: - the box starts unticked and its **?** shows the explanation; - an unticked link uses no STUN server and has no public address; - a ticked link uses Cloudflare's server, and the choice is remembered; - a guest in a second browser answers a cross-network invite with STUN while its own setting is off. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01N5Te9G1qTpJhPVvS4QMunF * [AUTOMATED] fix(p6): a Win64 home slot's address prints as the local that holds it (protoranges) (#903) kuna printed the address of a Win64 home slot as &Stack0000000000000018 beside a separate variable declared at the same slot, so the store and the call that reads it looked unrelated. Stock Ghidra prints one local: `code *local_res18 [2]; local_res18[0] = worker_proc; consume(local_res18);`. kuna never read a prototype's <localrange>, nor took its parameter range from the <input> stack entries, as upstream ProtoModel::decode does; every model used the defaults, under which the home area (stack 8..39 in x86-64-win.cspec) is parameter space and no local is mapped over it. The model now keeps the spec's ranges beside the defaults and `option protoranges` (default on, 0/675 datatest assertions moved) selects them. In Ghidra mode the host's 8-byte local_res18 is a name recommendation; it now renames the Symbol that starts at its address, as upstream recoverNameRecommendationsForSymbols does, instead of one 8-byte variable. Claude-Session: https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW Co-author…
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.
With kuna as Ghidra's decompiler, a string Ghidra has defined prints as its label, not as the literal. Stock Ghidra prints the literal. This is the norm in real programs: in 100 sampled Notepad++ x64 functions, kuna printed 80
s_/u_labels and stock printed none.kuna_FUN_1401eb1e0.c:stock_FUN_1401eb1e0.c:The fix
char[N]orwchar_t[N]. kuna's printer already prints such a reference as the literal, but first checks that the address is read-only, and it asked its local symbol table. In Ghidra mode that table is empty, so the answer was always "no" and the label won.Architecture::is_global_read_only, which asks the remote scope when one is installed, as upstream'sScopeGhidra::isReadOnlydoes. The standalone CLI takes the same path as before.Tests
ghidra_sim_pe_string_data_prints_as_literals: the sim oracle now answers a string's address in Java's shape. Onwidestrings_x86_64.exe, kuna printedLoadLibraryW(u_ntdll_dll_140002100)before this change and printsLoadLibraryW(L"ntdll.dll")after.🤖 Generated with Claude Code
https://claude.ai/code/session_01P5o4staUBV6w6hEVKucuZW