wasm-pack: 65214 segmentation fault (core dumped) wasm-pack help

πŸ› Bug description

I run wasm-pack help and it crashes (sometimes).

wasm-pack 0.9.1
Ashley Williams <ashley666ashley@gmail.com>
πŸ“¦ ✨  pack and publish your wasm!

USAGE:
    wasm-pack [FLAGS] [OPTIONS] <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -q, --quiet      No output printed to stdout
    -V, --version    Prints version information
    -v, --verbose    Log verbosity is based off the number of v used

OPTIONS:
        --log-level <log_level>    The maximum level of messages that should be logged by wasm-pack. [possible values:
                                   info, warn, error] [default: info]

SUBCOMMANDS:
    build      πŸ—οΈ  build your npm package!
    help       Prints this message or the help of the given subcommand(s)
    login      πŸ‘€  Add an npm registry user account! (aliases: adduser, add-user)
    new        πŸ‘ create a new project with a template
    pack       🍱  create a tar of your npm package but don't publish!
    publish    πŸŽ†  pack up your npm package and publish!
    test       πŸ‘©β€πŸ”¬  test your wasm!
malloc_consolidate(): invalid chunk size
[1]    65214 segmentation fault (core dumped)  wasm-pack help

πŸ€” Expected Behavior

Run without crash

πŸ‘Ÿ Steps to reproduce

cargo +stable install wasm-pack
wasm-pack help

🌍 Your environment

wasm-pack version: 0.9.1 rustc version: 1.42.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 10
  • Comments: 27 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I had a different problem with similar outcome: wasm-pack always segfaulted on wasm-pack build. For me the solution was to downgrade from wasm-pack 0.10.x to 0.9.1 like this: cargo install wasm-pack --version 0.9.1 Apparently 0.10.x introduced a bug

As I couldn’t find a workaround, I fiddled a bit with it myself. In the end, I ended up changing the curl dependency to use static-curl, which seems to be solving this issue (sadly, this cannot be done via patch, as that doesn’t support changing features):

-curl = "0.4.13"
+curl = { version = "0.4.13", features = ['static-curl'] }

In Config.toml. It seems the curl rust package doesn’t pin libcurl, and so it picks the latest. I can imagine that this libcurl is not compatible with my system libcurl. And making curl static solves that issue, as now it no longer depends on my system libcurl. But I am really guessing here, and stopped looking into this after my fixes unbroke my system πŸ˜ƒ

This issue is fixed after https://github.com/rustwasm/wasm-pack/pull/1176 merges. In particular this binaryen upgrade fixed the sigsegv.

Until that PR merges, you an use this command to get the fix:

cargo install --git https://github.com/frewsxcv/wasm-pack.git --branch patch-2

I am having the same issue, but only when building in a docker file. Running directly on my Computer it works fine.

The Dockerfile:

FROM rust:1
WORKDIR /opt
COPY my-folder .
RUN cargo install wasm-pack
RUN wasm-pack build

I first thought this might be caused by a newer rustc inside the docker, but both rustc and wasm-pack seem to be the same version:

Step 5/18 : RUN rustc --version
 ---> Running in c494bdd3da53
rustc 1.55.0 (c8dfcfe04 2021-09-06)
Removing intermediate container c494bdd3da53
 ---> 975680e06f36
Step 6/18 : RUN wasm-pack --version
 ---> Running in 15f2de23f1f5
wasm-pack 0.10.1
Removing intermediate container 15f2de23f1f5

Any ideas on how to fix this? adding RUST_BACKTRACE=1 has no effect.

EDIT: I tried using different versions of rustc (i.e. different version of the rust docker image), but none worked (1.54, 1.56, bullseye/buster, …). I also tried installing wasm-pack directly from git using cargo install --git https://github.com/rustwasm/wasm-pack, but no luck either. I am out of ideas at this point, especially as it used to work a few days ago

In my case I was missing crate-type metadata at Cargo.toml

[lib]
crate-type = ["cdylib", "rlib"]

Consider docs as reference

Edit: it seems not to be related to crate-type metadata. Installing version 0.9.1 solves the issue. Installing version 0.9.1 and installing version 0.10.1 also solves the issue.

You can recreate the issue with this docker image:

# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/javascript-node/.devcontainer/base.Dockerfile

# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-buster
ARG VARIANT="16"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

# Install emscripten dependencies
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
     && apt-get -y install --no-install-recommends cmake git python3 python3-pip

ENV EMSDK /emsdk

RUN git clone https://github.com/emscripten-core/emsdk.git ${EMSDK}
RUN cd ${EMSDK} \
    && ./emsdk install 1.40.1 \
    && ./emsdk activate 1.40.1 \
    && . ./emsdk_env.sh

USER node

# Install rust via rustup
ARG RUST_VERSION=1.56.1
RUN curl https://sh.rustup.rs -sSf | \
    sh -s -- -y --default-toolchain $RUST_VERSION && \
    . ~/.cargo/env && \
    rustup target add asmjs-unknown-emscripten && \
    rustup target add wasm32-unknown-emscripten && \
    rustup target add wasm32-unknown-unknown

RUN echo "source ~/.cargo/env" >> ~/.bashrc

An vscode dev container is included if someone else is interested:

{
	"name": "Node.js",
	"build": {
		"dockerfile": "Dockerfile",
		"args": { "VARIANT": "16" }
	},
	"settings": {},
	"extensions": [
		"dbaeumer.vscode-eslint",
		"ms-vscode.cpptools-extension-pack",
		"rust-lang.rust",
		"serayuzgur.crates"
	],
	"remoteUser": "node",
	"features": {}
}

Seeing same issue on wasm-pack 0.9.1, ubuntu 20.04

Same issue here on a clean install:

$Β rustc -V
rustc 1.57.0 (Arch Linux rust 1:1.57.0-1)

$ wasm-pack -V
wasm-pack 0.10.1

$ wasm-pack new hello-wasm
[INFO]: Installing cargo-generate...
Segmentation fault (core dumped)

Works when downgrading to 0.9.1

For me, it works fine if I install without default features (--no-defaults-features).