question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error in multithreading with wasm-pack and webassembly rust

See original GitHub issue

Bug report

What is the current behavior?

When compiling https://github.com/iMplode-nZ/rust-webpack-multithreading-test via (p)npm watch using webpack 5.49.0 and the latest rust and the rust flags -Ctarget-feature=+atomics,+bulk-memory,+mutable-globals, I get this error:

webpack compiled with 1 error
ERROR in ./pkg/index_bg.wasm
Module parse failed: Unexpected section: 0xc
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Error: Unexpected section: 0xc

If the current behavior is a bug, please provide the steps to reproduce.

Clone https://github.com/iMplode-nZ/rust-webpack-multithreading-test, npm install, npm serve.

What is the expected behavior?

It does not error.

Other relevant information: webpack version: 5.49.0 Node.js version: 14.4.0 Operating System: Ubuntu 20.04 focal Additional tools:

rustc 1.56.0-nightly (4e282795d 2021-07-31)
wasm-bindgen 0.2.75
wasm-pack 0.10.0

I’m putting this here as it seems more like a webpack bug than a wasm-pack/bindgen/rust bug. See wasm-pack issue at https://github.com/rustwasm/wasm-pack/issues/1050

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mattzquecommented, Nov 23, 2021

Same issue here

“Unexpected section: 0xc” throws in wasm-async, or more precisely it crashes in @webassemblyjs/wasm-parser. This is a minimal example to reproduce the error:

const { decode } = require("@webassemblyjs/wasm-parser");
const fs = require('fs');

decode(fs.readFileSync('file.wasm'), {
  ignoreCodeSection: true,
  ignoreDataSection: true,
  ignoreCustomNameSection: true,
})

example files to reproduce: wasm_parse_bug.zip

I compiled the hello world example with wasm-pack:

wasm_parse_bug/hello_wasm_bg_working.wasm: (this works perfectly fine in webpack) compiled with: wasm-pack build

wasm_parse_bug/hello_wasm_bg_broken.wasm: (this causes the 0xc error) compiled with: RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals" wasm-pack build

0reactions
webpack-botcommented, Aug 30, 2022

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multithreading Rust and Wasm
This means that the instantiation of a wasm module will automatically create an instance of WebAssembly. Memory and make it available for use....
Read more >
Using WebAssembly threads from C, C++ and Rust - web.dev
In this article you will learn how to use WebAssembly threads to bring multithreaded applications written in languages like C, C++, and Rust...
Read more >
Why do these rustflags give me an out of memory exception?
I am working on a web assembly application in rust. The program relies on streaming a file and storing the data in memory....
Read more >
Node worker threads with shared array buffers and Rust ...
WebAssembly enables Rust to run as part of a JavaScript code, ... By compiling it with wasm-pack , we get a full JS...
Read more >
[WASM/Rust] Multithreading / stack size control
There is no multithreading in wasm. Eventually it will get added. If your doing a node.js project neon might (never tried) be an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found