WebAssembly / WebAssembly/wabt

wasm-decompile decompile error

Open
#2,475 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

wasm-decompile
Dominant language
C++
Stars
8.1k
Forks
827
Avg merge
4d 6h
Merged PRs (30d)
18

Description

Hi wabt team,

Recently I have been testing the decompile tool chain of WebAssembly. This is conducted by comparing the results of a C program:

  • compile into WASM, decompile with wasm-decompile, rewrite syntax and re-compile into native binary.
  • directly compile into native binary.

A few execution discrepancies are discovered during this process.
One is as the displayed code snipped. It seems like the recovered data flow is incorrect.
image
image

May I ask if this is an implementation error, or am I missing anything here?

Attaching the files related to this report. 198.zip

  • 198.c: A C program generated with csmith. The goal is to compare the final hash value after executing func_1.
  • 198 is the compiled WASM
  • 198_wasm-decompile.c: Decompiled result by wasm-decompile.
  • 198_new.c: Extract the decompiled func_1 in 198_wasm-decompile.c and fix the syntax to make it re-compilable

Thank you

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the discrepancy with the attached 198.c, 198, 198_wasm-decompile.c, and 198_new.c files using wasm-decompile. Compare the recovered data flow and final hash against the original C program, then determine whether the discrepancy is an implementation error and document a minimal reproducible case if confirmed.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp, wasm
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.