Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasi fast calls causes segfault on x86_64-linux when running a wasm32-wasi module #53087

Open
TerrorJack opened this issue May 21, 2024 · 0 comments
Labels
wasi Issues and PRs related to the WebAssembly System Interface.

Comments

@TerrorJack
Copy link
Contributor

Version

v22.2.0

Platform

Linux build01 6.7.9 #1-NixOS SMP PREEMPT_DYNAMIC Wed Mar 6 14:54:01 UTC 2024 x86_64 GNU/Linux

Subsystem

wasi

What steps will reproduce the bug?

https://files.catbox.moe/izkaki.zst

The above .tar.zst tarball contains openFile008.wasm and wasm-run.mjs in the same directory. openFile008.wasm is a Haskell program compiled from this file that simply creates a temporary directory, then opens/closes some empty files within it. wasm-run.mjs is a script to run it:

#!/usr/bin/env -S node --no-warnings --experimental-wasi-unstable-preview1

import fs from "node:fs/promises";
import { WASI } from "node:wasi";

const wasi = new WASI({
  version: "preview1",
  args: ["openFile008.wasm"],
  env: { PATH: "" },
  preopens: { "/": process.cwd() },
  returnOnExit: false,
});

const instance = (
  await WebAssembly.instantiate(await fs.readFile("openFile008.wasm"), {
    wasi_snapshot_preview1: wasi.wasiImport,
  })
).instance;

wasi.start(instance);

Now, simply run the script above.

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

It should quickly run to completion without any issue. This is the expected behavior you get by running it with wasmtime run .::/ -- openFile008.wasm, or using node v18 to run the repro script.

What do you see instead?

node process segfaults.

Additional information

I have tried to bisect this breakage on the main branch. The offending commit is b3bf07e that landed #43697. cc @devsnek

@VoltrexKeyva VoltrexKeyva added the wasi Issues and PRs related to the WebAssembly System Interface. label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasi Issues and PRs related to the WebAssembly System Interface.
Projects
None yet
Development

No branches or pull requests

2 participants