Skip to content

fix(wasm): preserve debug module names in WABT output - #1967

Merged
morluto merged 3 commits into
morluto:mainfrom
bugstan:fix/wasm-debug-module-names
Oct 11, 2026
Merged

morluto merged 3 commits into
morluto:mainfrom
bugstan:fix/wasm-debug-module-names

Conversation

@bugstan

@bugstan bugstan commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Valid WASM modules carrying a debug module name fail inspect_wasm_artifact / inspect-wasm-artifact after successful WABT validation: the adapter rejects the additional module name: <...> preamble. Accept and preserve this producer output without changing the public schema or section-range checks.

This is a newly reproduced bug, so there is no existing issue to close. It is separate from the unpadded DataCount row in #1956 / merged #1963; this PR does not change that row pattern.

Problem and expected behavior

Compile the following with WABT 1.0.42 wat2wasm --debug-names, then inspect it through the CLI or MCP:

(module $named
  (func (export "answer") (result i32) i32.const 42))

Both interfaces currently return unreadable_output, reason Unsupported WABT section header format. They should return the valid artifact Evidence, including the exact module-name preamble in headers and details.

Change and scope

WABT prints raw module names, which can contain newlines and apparent section delimiters. Its WAT identifier also replaces invalid identifier bytes, so that identifier cannot reconstruct the raw name. Reuse the existing WAT string decoder and read only module-name metadata from WABT's preserved @custom "name" payloads. Use those ordered names to frame the exact objdump preamble, including its NUL-terminated display behavior. No raw WASM parser or target mutation is introduced.

Preserve the preamble in both header and detail views. Add real CLI/MCP fixtures for compiler-generated names and custom metadata with empty, multiline, Unicode, long and NUL-containing names. Keep malformed-output and metadata-boundary refusals in the parser tests.

Contract and boundary impact

  • Semantic owner and earliest changed stage: WABT output decoding, after producer validation.
  • CLI and MCP/tool-catalog contract: unchanged inputs and schemas; formerly rejected named modules return Evidence.
  • Provider, bridge, target-format, or platform compatibility: existing WABT 1.0.42 profile; real verification on WSL/Linux x64.
  • Evidence, artifact, provenance, or reconstruction contract: preserve exact WAT, header/detail text, artifact/tool digests, section ranges and retained records.
  • Process execution, authorization, cleanup, or containment impact: none; existing owned-process and workspace lifecycle reused.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: exact-name preamble mismatches and truncated name metadata; real-WABT workflow and source-owned WAT fixture.

  • Base reproduction: on unmodified upstream 39418ea1, actual compiled CLI and fresh stdio MCP both returned unreadable_output for the source above. A following MCP ping succeeded. Official WABT validation succeeded.

  • User-visible output after the fix: valid inline Evidence; CLI/MCP values and Evidence IDs match, as do independent wasm-objdump -h / -x output and decoded WAT.

  • Remaining proof gaps: Windows/macOS WABT hosts, packaged-install verification and the full deterministic suite were not run. No native engine or target execution is involved.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Pinned Node 24.18.0 / npm 11.16.0; official WABT 1.0.42 Linux x64 archive SHA-256 84895407a6bbb80e918f33b16b2fb2206021c150b6bc9ff6f761263a745ab131, checked against release metadata.

  • npm run test:focused -- src/wasm/WabtOutput.test.ts src/wasm/WabtArtifactProvider.test.ts tests/boundary/mcp/wasmArtifactMcp.test.ts — 20 tests passed after integrating upstream 9eee709f.
  • npm run verify:wasm:artifact -- --require-tools with explicit WABT directory — 42 cases passed after integrating upstream 9eee709f, including its DataCount control. Inputs remained unchanged, provider workspaces were cleaned up and verified process lineage had no remaining descendants.
  • npm run check — all six tasks and architecture guards passed. Existing lint warnings remain; zero lint errors.
  • npm run docs:check — all six tasks passed.
  • git diff --check — passed.
  • Independent review of name metadata against the pinned WABT producer found no actionable medium/high issue.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: real WABT on WSL/Linux x64 only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no added authority or executable changes; raw names cannot substitute for parser delimiters, and existing malformed-output/range checks remain.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T21:49:17.035165Z 2f101dc New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

bugstan and others added 2 commits October 12, 2026 04:34
Preserve modern dylib options while requiring one encoding metadata row and retaining duplicate and multiline-output checks. Share field parsing between preservation and validation.

Verify delayed dylibs through real macOS CLI/MCP workflows and refresh the high-address golden with the provider's -h -l capture. Validated 85 focused native tests, npm run check, and verify:macos-bundle on macOS arm64.
@morluto
morluto merged commit b777e5d into morluto:main Oct 11, 2026
23 of 24 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 11, 2026
3 tasks done

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f101dc665

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const requireUniqueField = (block: string, key: string): void => {
const escaped = key.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
const pattern = new RegExp(`^\\s*${escaped}\\s+`, "mu");
const pattern = new RegExp(`^\\s*${escaped}(?:\\s|$)`, "mu");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict bare-field matching to empty options

When otool output is malformed or truncated immediately after a required field label such as entryoff, uuid, or vmaddr, the new end-of-line alternative makes requireUniqueField count that bare label even though parseField drops it. parseOtoolLoadCommands therefore accepts the command and emits an empty entrypoint or null UUID/address rather than surfacing unreadable producer output; allow an end-of-line value only for the deliberately empty options row.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

Comment thread src/wasm/WabtWat.ts
);
customSectionNames.push(name);
if (name === "name") {
const payloadPrefix = /^\s+"/u.exec(form.slice(nameString.end));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle placement before decoding name payloads

For a valid module whose name custom section is not in the default trailing position, WABT can preserve that position in decoded WAT as (@custom "name" (after code) "..."). This regex only accepts whitespace followed immediately by the payload quote, so parseWabtWat throws after successful validation and inspection returns unreadable_output; consume the optional placement annotation before decoding the payload.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

morluto pushed a commit that referenced this pull request Oct 12, 2026
#1995)

* fix(native): reject required otool fields truncated before their value

#1967 let requireUniqueField count a label at end of line so an empty
dylib-use options row is present. That applied to every required field,
so truncated output such as a bare vmaddr, vmsize, uuid or entryoff line
passed the presence check while parseField dropped it, and the value
silently became null.

Let parseField decide which labeled line carries a value: the single
matching line must parse as that field. The empty options row remains
the only valueless field parseField admits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(native): admit the empty segname of Mach-O object files

MH_OBJECT files put their sections in one segment whose name is empty,
and otool -l prints it as a bare segname label. Requiring a value for
every scalar field rejected valid object-file output as unreadable.

Let parseField admit an empty segname like the empty dylib-use options
row, and keep projecting an empty or absent segment name as "unknown",
as main did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(native): admit all-NUL Mach-O section names

An all-NUL section_64.sectname prints as a bare sectname label, like an
empty segname. Admit it in parseField and keep projecting the empty name
as "unknown", as main did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto morluto added the provider: wabt Analysis provider / engine: wabt label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working provider: wabt Analysis provider / engine: wabt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants