Reasoning from Traces: Divergence-Guided Agentic Repair of WebAssembly Discrepancies

arXiv:2608.05521 · cs.SE · Submitted 2026-08-06 · Read on arXiv

cs.SE

Submitted: 2026-08-06

Updated: 2026-10-28

Code: https://github.com/fmtlib/fmt

Project page: https://webassembly.github.io/spec/core/intro/introduction.html

License: http://creativecommons.org/licenses/by/4.0/

The gist: WebAssembly (Wasm) promises seamless reuse of C/C++ codebases as portable, efficient, sandboxed binaries for execution on the Web.

Terminology

Abstract

WebAssembly (Wasm) promises seamless reuse of C/C++ codebases as portable, efficient, sandboxed binaries for execution on the Web. In practice, however, this promise often falls short: recent studies show that cross-compiling C/C++ source to Wasm and native binaries frequently produces runtime discrepancies due to differences in library implementation and compiler bugs. Since the root causes are platform-level and hidden beneath the source code, even state-of-the-art LLM-based coding agents can struggle to diagnose and repair these discrepancies. In this paper, we present WasmMend, the first system for automatically repairing Native-Wasm functional discrepancies. WasmMend transforms open-ended debugging into a two-stage process. First, a novel differential trace analysis approach localizes the function where Wasm and native executions first diverge. Second, guided by this localization, a multi-agent system coordinates separate agents to interpret platform-specific behavior and synthesizes patch plans. Experiments on discrepancies from real-world C/C++ projects show that, across five backbone models, WasmMend achieves a fix rate of up to 84.8%, with average gains of at least 37.2 percentage points over the evaluated open-source coding agent baselines, while maintaining comparable cost.

Sources

Related papers