Skip to content

"wasm error: Function: Module doesn't have export fuzz" with Rust 1.89 #40

@mleonhard

Description

@mleonhard

I built the sidefuzz binary from source at 6e7038a, with tylerreisinger/rust-float-duration@7d63436d to work around tylerreisinger/rust-float-duration#6 .

I built my library with cargo build --release --target wasm32-unknown-unknown and Rust 1.89. When I run sidefuzz fuzz target/wasm32-unknown-unknown/release/proj.wasm it crashes:

   Compiling sidefuzz v0.1.2 (https://github.com/phayes/sidefuzz.git?rev=6e7038a2#6e7038a2)
   Compiling proj v0.1.0 (/proj)
    Finished `release` profile [optimized] target(s) in 0.12s
The application panicked (crashed).
Message:  called `Result::unwrap()` on an `Err` value: Validation("Unknown opcode 252")
Location: src/wasm.rs:20

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                              ⋮ 10 frames hidden ⋮                              
11: sidefuzz::wasm::WasmModule::new::h9701ba95d9aee1bd
    at <unknown source file>
12: sidefuzz::wasm::WasmModule::from_file::h2fbbd54f1374bd55
    at <unknown source file>
13: sidefuzz::fuzz::Fuzz::from_file::hade4f71e9390f7b4
    at <unknown source file>
14: sidefuzz::main::h72b93917929ba265
    at <unknown source file>
15: std::sys::backtrace::__rust_begin_short_backtrace::h8c99f3992291e116
    at <unknown source file>
16: std::rt::lang_start::{{closure}}::h69d173a41e82869f
    at <unknown source file>
17: std::rt::lang_start_internal::h9c67c334770c9206
    at <unknown source file>
18: _main
    at <unknown source file>

I guess sidefuzz is using an old wasm runtime that can't read the wasm code produced by modern rustc.

I tried building with all wasm features turned off:

RUSTFLAGS="-Ctarget-cpu=mvp" cargo \
 +nightly \
 build \
 -Zbuild-std=panic_abort,std \
 --target wasm32-unknown-unknown \
 --release

This yields a different error:

Error: wasm error: Function: Module doesn't have export fuzz

The module does export fuzz:

// lib.rs
use rpc::Tag;
use sidefuzz::{black_box, fetch_input};

#[allow(clippy::missing_panics_doc)]
pub extern "C" fn fuzz() {
    let input = fetch_input(32);
    let tag0 = Tag(input[..16].try_into().unwrap());
    let tag1 = Tag(input[16..].try_into().unwrap());
    black_box(tag0 == tag1);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions