wasm-pack icon indicating copy to clipboard operation
wasm-pack copied to clipboard

wasm-pack build segfaults in Docker

Open evdokimovs opened this issue 4 years ago • 5 comments

🐛 Bug description

When I trying to build dummy library with wasm-pack build -t web . it segfaults in Docker. On host machine it works fine.

👟 Steps to reproduce

  1. git clone https://github.com/evdokimovs/wasm-pack-segfault.git
  2. docker build .

Or you can just look at this error on different Rust version in CI.

Concrete error log:

Step 4/4 : RUN cd /src/ && wasm-pack build -t web .
 ---> Running in 82f7047e8a8c
Segmentation fault (core dumped)
The command '/bin/sh -c cd /src/ && wasm-pack build -t web .' returned a non-zero code: 139

🌍 Your environment

  • wasm-pack version: wasm-pack 0.10.1
  • rustc version: rustc 1.56.1 (59eed8a2a 2021-11-01) (also tested on 1.54 and 1.55 versions)
  • Docker version: Docker version 20.10.8, build 3967b7d28e
  • Host Linux version: 5.13.10
  • Docker image: official Rust image on Docker Hub

evdokimovs avatar Nov 09 '21 14:11 evdokimovs

This seems to have been introduced in 0.10.0 and can be fixed by downgrading to 0.9.1.

connor4312 avatar Nov 11 '21 05:11 connor4312

I'm seeing the same issue (under podman):

(gdb) r
Starting program: /usr/local/cargo/bin/wasm-pack build --release --no-typescript --target web --out-name wasm --out-dir ./static
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff6df8700 (LWP 2379)]
[New Thread 0x7ffff6bf7700 (LWP 2380)]
[Detaching after vfork from child process 2381]
[Thread 0x7ffff6bf7700 (LWP 2380) exited]

Thread 2 "wasm-pack" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff6df8700 (LWP 2379)]
0x00007ffff7ac9143 in SSL_get_peer_certificate () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
(gdb) bt
#0  0x00007ffff7ac9143 in SSL_get_peer_certificate () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#1  0x00007ffff7f92697 in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#2  0x00007ffff7f9666e in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#3  0x00007ffff7f97421 in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#4  0x00007ffff7f55d52 in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#5  0x00007ffff7f6c98d in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#6  0x00007ffff7f6dc06 in curl_multi_perform () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#7  0x00007ffff7f44943 in curl_easy_perform () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#8  0x00005555557045a0 in wasm_pack::manifest::Crate::return_api_call_result ()
#9  0x0000555555704078 in wasm_pack::manifest::Crate::return_wasm_pack_latest_version ()
#10 0x00005555556c4b04 in wasm_pack::build::check_wasm_pack_versions ()
#11 0x00005555556a86f5 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
#12 0x00005555556a5c13 in core::ops::function::FnOnce::call_once{{vtable-shim}} ()
#13 0x0000555555c6b933 in alloc::boxed::{impl#44}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> ()
    at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/alloc/src/boxed.rs:1636
#14 alloc::boxed::{impl#44}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> ()
    at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/alloc/src/boxed.rs:1636
#15 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:106
#16 0x00007ffff7d2eea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#17 0x00007ffff7e5fdef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

The base image is docker.io/library/rust:1.56.1-bullseye

root@e4c850af6269:/s# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye
root@e4c850af6269:/s# rustc --version
rustc 1.56.1 (59eed8a2a 2021-11-01)
root@e4c850af6269:/s# cargo --version
cargo 1.56.0 (4ed5d137b 2021-10-04)
root@e4c850af6269:/s# wasm-pack --version
wasm-pack 0.10.1
root@ed0a9ae556a3:/s# dpkg -l libssl1.1 libcurl4
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name            Version          Architecture Description
+++-===============-================-============-==============================================================
ii  libcurl4:amd64  7.74.0-1.3+b1    amd64        easy-to-use client-side URL transfer library (OpenSSL flavour)
ii  libssl1.1:amd64 1.1.1k-1+deb11u1 amd64        Secure Sockets Layer toolkit - shared libraries

diegov avatar Nov 13 '21 01:11 diegov

I'm seeing the same in my host OS, Manjaro Linux on x86_64. 0.10.0 and 0.10.1 worked fine on WSL2 Ubuntu for me, just not on Manjaro.

Reverting to wasm-pack 0.9.1 also fixed this for me - thanks @connor4312

sdd avatar Nov 14 '21 17:11 sdd

This is not a problem with wasm-pack.

This segfault began with the release of openssl-sys v0.9.69. It bumped its bundled OpenSSL sources to version 3.0.0, causing problems for systems with earlier versions of OpenSSL (the Docker image ships with version 1.1). This particular crash occurs because the OpenSSL 1.1 SSL_get_peer_certificate is used on a context initialized with 3.0.0's SSL_clear. The system's libcurl is calling both of those functions, but because the openssl crates export a conflicting SSL_clear, libcurl uses the wrong version of OpenSSL (the 3.0.0 linked into the binary, not the libssl 1.1 on the system that it was really built against).

The issue should be reported against the openssl crates instead. Any workaround that restricts openssl-sys to <=0.9.68 should suffice for now.

CFSworks avatar Nov 15 '21 05:11 CFSworks

linking the other comment from #997

https://github.com/rustwasm/wasm-pack/issues/997#issuecomment-970870821

sassman avatar Nov 16 '21 23:11 sassman