Skip to content
New issue

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

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

Already on GitHub? # to your account

wasm-pack build segfaults #1203

Closed
yath opened this issue Dec 22, 2022 · 8 comments · Fixed by #1290
Closed

wasm-pack build segfaults #1203

yath opened this issue Dec 22, 2022 · 8 comments · Fixed by #1290

Comments

@yath
Copy link

yath commented Dec 22, 2022

🐛 Bug description

Running wasm-pack build in https://github.com/Boddlnagg/midir/tree/master/examples/browser gives a segmentation fault.

🤔 Expected Behavior

It should have built a pack.

👟 Steps to reproduce

$ git clone https://github.com/Boddlnagg/midir/
$ cd midir/examples/browser
$ wasm-pack build               
zsh: segmentation fault  wasm-pack build
$

A stack trace from GDB (RUST_BACKTRACE=1 didn’t print anything):

#0  0x0000555555855494 in OPENSSL_sk_value ()
#1  0x000055555585c8ca in X509_STORE_add_lookup ()
#2  0x00007ffff76d580b in X509_STORE_load_file_ex (ctx=0x7ffff0010b30, file=file@entry=0x7ffff00095f0 "/etc/ssl/certs/ca-certificates.crt", libctx=0x555555e545c0 <TLS_client_method_data.14>, propq=0x0) at ../crypto/x509/x509_d2.c:51
#3  0x00007ffff7ab6e63 in SSL_CTX_load_verify_file (ctx=<optimized out>, CAfile=CAfile@entry=0x7ffff00095f0 "/etc/ssl/certs/ca-certificates.crt") at ../ssl/ssl_lib.c:4425
#4  0x00007ffff7f52ea0 in ossl_connect_step1 (data=data@entry=0x7ffff0001f20, conn=conn@entry=0x7ffff0008df0, sockindex=sockindex@entry=0) at vtls/openssl.c:3362
#5  0x00007ffff7f55817 in ossl_connect_common (data=0x7ffff0001f20, conn=0x7ffff0008df0, sockindex=0, nonblocking=true, done=0x7ffff6c8b3b3) at vtls/openssl.c:4059
#6  0x00007ffff7f56868 in Curl_ssl_connect_nonblocking (data=data@entry=0x7ffff0001f20, conn=conn@entry=0x7ffff0008df0, isproxy=isproxy@entry=false, sockindex=sockindex@entry=0, done=done@entry=0x7ffff6c8b3b3) at vtls/vtls.c:371
#7  0x00007ffff7f0d256 in https_connecting (done=0x7ffff6c8b3b3, data=0x7ffff0001f20) at ./debian/build/lib/http.c:1650
#8  Curl_http_connect (data=0x7ffff0001f20, done=0x7ffff6c8b3b3) at ./debian/build/lib/http.c:1576
#9  0x00007ffff7f2661c in protocol_connect (protocol_done=0x7ffff6c8b3b3, data=0x7ffff0001f20) at ./debian/build/lib/multi.c:1773
#10 multi_runsingle (multi=multi@entry=0x7ffff00011e0, nowp=nowp@entry=0x7ffff6c8b430, data=data@entry=0x7ffff0001f20) at ./debian/build/lib/multi.c:2089
#11 0x00007ffff7f27536 in curl_multi_perform (multi=multi@entry=0x7ffff00011e0, running_handles=running_handles@entry=0x7ffff6c8b538) at ./debian/build/lib/multi.c:2682
#12 0x00007ffff7efd94b in easy_transfer (multi=<optimized out>) at ./debian/build/lib/easy.c:663
#13 easy_perform (events=false, data=0x7ffff0001f20) at ./debian/build/lib/easy.c:753
#14 curl_easy_perform (data=0x7ffff0001f20) at ./debian/build/lib/easy.c:772
#15 0x00005555556df7a4 in wasm_pack::manifest::Crate::return_api_call_result ()
#16 0x00005555556df3b5 in wasm_pack::manifest::Crate::return_wasm_pack_latest_version ()
#17 0x0000555555685ddd in wasm_pack::build::check_wasm_pack_versions ()
#18 0x000055555565c605 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
#19 0x00005555556641c9 in core::ops::function::FnOnce::call_once{{vtable.shim}} ()
#20 0x0000555555b882a3 in alloc::boxed::{impl#44}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:1940
#21 alloc::boxed::{impl#44}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:1940
#22 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#23 0x00007ffff7d85fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#24 0x00007ffff7e0666c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

🌍 Your environment

Include the relevant details of your environment.
wasm-pack version: 0.10.3 (installed via cargo)
rustc version: 1.65.0 (897e37553 2022-11-02)

@katopz
Copy link

katopz commented Dec 24, 2022

I think it should be wasm-pack build --target=no-modules --dev refer to https://github.com/Boddlnagg/midir/blob/master/azure-pipelines-template.yml#L103

or maybe wasm-pack build --target=web should work.

@yath
Copy link
Author

yath commented Dec 26, 2022

That gives the same error with the same stack trace unfortunately. IIUC, wasm-pack is attempting to download something with libcurl, which is using OpenSSL, which then crashes for some reason. My /usr/bin/curl works fine though, also with SSL connections.

@antobun
Copy link

antobun commented Dec 29, 2022

I get a segfault too.

rustc 1.66.0 (69f9c33d7 2022-12-12)
wasm-pack 0.10.3
curl 7.87.0 (x86_64-pc-linux-gnu) libcurl/7.87.0 OpenSSL/3.0.7 zlib/1.2.13 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.4 libpsl/0.21.1 (+libidn2/2.3.4) libssh2/1.10.0 nghttp2/1.51.0

Stacktrace:

#0  ___pthread_rwlock_wrlock (rwlock=0x35) at pthread_rwlock_wrlock.c:26
#1  0x00007ffff77c98fe in CRYPTO_THREAD_write_lock () from /usr/lib/libcrypto.so.3
#2  0x00007ffff7836e15 in ?? () from /usr/lib/libcrypto.so.3
#3  0x00007ffff7836eb1 in X509_STORE_add_cert () from /usr/lib/libcrypto.so.3
#4  0x00007ffff781b500 in X509_load_cert_crl_file_ex () from /usr/lib/libcrypto.so.3
#5  0x00007ffff781b656 in ?? () from /usr/lib/libcrypto.so.3
#6  0x00007ffff783697a in X509_STORE_load_file_ex () from /usr/lib/libcrypto.so.3
#7  0x00007ffff7f4bfe2 in populate_x509_store (store=0x7ffff00103b0, data=0x7ffff0000f90,
    cf=0x7ffff00097a0) at /usr/src/debug/curl/curl-7.87.0/lib/vtls/openssl.c:3262
#8  set_up_x509_store (backend=0x7ffff0009770, data=0x7ffff0000f90, cf=0x7ffff00097a0)
    at /usr/src/debug/curl/curl-7.87.0/lib/vtls/openssl.c:3454
#9  ossl_connect_step1 (cf=cf@entry=0x7ffff00097a0, data=data@entry=0x7ffff0000f90)
    at /usr/src/debug/curl/curl-7.87.0/lib/vtls/openssl.c:3776
#10 0x00007ffff7f4d327 in ossl_connect_common (cf=0x7ffff00097a0, data=0x7ffff0000f90, nonblocking=true,
    done=0x7ffff721756c) at /usr/src/debug/curl/curl-7.87.0/lib/vtls/openssl.c:4385
#11 0x00007ffff7f44bdc in ssl_connect_nonblocking (done=0x7ffff721756c, data=0x7ffff0000f90,
    cf=0x7ffff00097a0) at /usr/src/debug/curl/curl-7.87.0/lib/vtls/vtls.c:357
#12 ssl_cf_connect (done=0x7ffff721756c, blocking=false, data=0x7ffff0000f90, cf=0x7ffff00097a0)
    at /usr/src/debug/curl/curl-7.87.0/lib/vtls/vtls.c:1526
#13 ssl_cf_connect (cf=0x7ffff00097a0, data=0x7ffff0000f90, blocking=<optimized out>, done=0x7ffff721756c)
    at /usr/src/debug/curl/curl-7.87.0/lib/vtls/vtls.c:1493
#14 0x00007ffff7f203eb in Curl_conn_connect (done=0x7ffff721756c, blocking=false, sockindex=0,
    data=0x7ffff0000f90) at /usr/src/debug/curl/curl-7.87.0/lib/cfilters.c:367
#15 multi_runsingle (multi=multi@entry=0x7ffff0002850, nowp=nowp@entry=0x7ffff7217620,
    data=data@entry=0x7ffff0000f90) at /usr/src/debug/curl/curl-7.87.0/lib/multi.c:2070
#16 0x00007ffff7f2341e in curl_multi_perform (multi=0x7ffff0002850, running_handles=0x7ffff7217728)
    at /usr/src/debug/curl/curl-7.87.0/lib/multi.c:2690
#17 0x00007ffff7ef8a84 in easy_transfer (multi=<optimized out>)
    at /usr/src/debug/curl/curl-7.87.0/lib/easy.c:662
#18 easy_perform (events=false, data=0x7ffff0000f90) at /usr/src/debug/curl/curl-7.87.0/lib/easy.c:752
#19 curl_easy_perform (data=0x7ffff0000f90) at /usr/src/debug/curl/curl-7.87.0/lib/easy.c:771
#20 0x00005555556e2ed4 in wasm_pack::manifest::Crate::return_api_call_result ()
#21 0x00005555556e2ae5 in wasm_pack::manifest::Crate::return_wasm_pack_latest_version ()
#22 0x0000555555688e1d in wasm_pack::build::check_wasm_pack_versions ()
#23 0x000055555565fed5 in _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h6683c44776f977e6E.llvm.13230716178275419198 ()
#24 0x0000555555665d4d in core::ops::function::FnOnce::call_once{{vtable.shim}} ()
#25 0x0000555555b90e43 in alloc::boxed::{impl#45}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:1987
#26 alloc::boxed::{impl#45}::call_once<(), alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:1987
#27 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#28 0x00007ffff7d788fd in start_thread (arg=<optimized out>) at pthread_create.c:442
#29 0x00007ffff7dfaa60 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

@lanxu
Copy link

lanxu commented Jan 2, 2023

As a workaround, I compiled wasm-pack with non-optional openssl crate and disabled all features. This effectively disables the vendored build. I no longer get segfaults.

@Kerosin3
Copy link

Kerosin3 commented Jan 7, 2023

Have the same issue. Seems like something gone wrong with openSSL

rustc 1.68.0-nightly
wasm-pack 0.10.3

#0  ___pthread_rwlock_wrlock (rwlock=0x35) at pthread_rwlock_wrlock.c:26
#1  0x00007ffff77c98fe in CRYPTO_THREAD_write_lock () from /usr/lib/libcrypto.so.3
#2  0x00007ffff7836e15 in ?? () from /usr/lib/libcrypto.so.3
#3  0x00007ffff7836eb1 in X509_STORE_add_cert () from /usr/lib/libcrypto.so.3
#4  0x00007ffff781b500 in X509_load_cert_crl_file_ex () from /usr/lib/libcrypto.so.3
#5  0x00007ffff781b656 in ?? () from /usr/lib/libcrypto.so.3
#6  0x00007ffff783697a in X509_STORE_load_file_ex () from /usr/lib/libcrypto.so.3
#7  0x00007ffff7f62fe2 in populate_x509_store (store=0x7ffff0000ba0, data=0x7ffff0001910, cf=0x7ffff0009ea0) at /usr/src/debug/curl/curl-7.87.0/lib/vtls/openssl.c:3262
#8  set_up_x509_store (backend=0x7ffff0009e70, data=0x7ffff0001910, cf=0x7ffff0009ea0) at /usr/src/debug/curl/curl-7.87.0/lib/vtls/openssl.c:3454
#9  ossl_connect_step1 (cf=cf@entry=0x7ffff0009ea0, data=data@entry=0x7ffff0001910) at /usr/src/debug/curl/curl-7.87.0/lib/vtls/openssl.c:3776
#10 0x00007ffff7f64327 in ossl_connect_common (cf=0x7ffff0009ea0, data=0x7ffff0001910, nonblocking=true, done=0x7ffff722f56c) at /usr/src/debug/curl/curl-7.87.0/lib/vtls/openssl.c:4385
#11 0x00007ffff7f5bbdc in ssl_connect_nonblocking (done=0x7ffff722f56c, data=0x7ffff0001910, cf=0x7ffff0009ea0) at /usr/src/debug/curl/curl-7.87.0/lib/vtls/vtls.c:357
#12 ssl_cf_connect (done=0x7ffff722f56c, blocking=false, data=0x7ffff0001910, cf=0x7ffff0009ea0) at /usr/src/debug/curl/curl-7.87.0/lib/vtls/vtls.c:1526
#13 ssl_cf_connect (cf=0x7ffff0009ea0, data=0x7ffff0001910, blocking=, done=0x7ffff722f56c) at /usr/src/debug/curl/curl-7.87.0/lib/vtls/vtls.c:1493
#14 0x00007ffff7f373eb in Curl_conn_connect (done=0x7ffff722f56c, blocking=false, sockindex=0, data=0x7ffff0001910) at /usr/src/debug/curl/curl-7.87.0/lib/cfilters.c:367
#15 multi_runsingle (multi=multi@entry=0x7ffff0002f50, nowp=nowp@entry=0x7ffff722f620, data=data@entry=0x7ffff0001910) at /usr/src/debug/curl/curl-7.87.0/lib/multi.c:2070
#16 0x00007ffff7f3a41e in curl_multi_perform (multi=0x7ffff0002f50, running_handles=0x7ffff722f728) at /usr/src/debug/curl/curl-7.87.0/lib/multi.c:2690
#17 0x00007ffff7f0fa84 in easy_transfer (multi=) at /usr/src/debug/curl/curl-7.87.0/lib/easy.c:662
#18 easy_perform (events=false, data=0x7ffff0001910) at /usr/src/debug/curl/curl-7.87.0/lib/easy.c:752
#19 curl_easy_perform (data=0x7ffff0001910) at /usr/src/debug/curl/curl-7.87.0/lib/easy.c:771
#20 0x00005555556e6dd1 in wasm_pack::manifest::Crate::return_api_call_result ()
#21 0x00005555556e69f1 in wasm_pack::manifest::Crate::return_wasm_pack_latest_version ()
#22 0x0000555555689d43 in wasm_pack::build::check_wasm_pack_versions ()
#23 0x0000555555660045 in _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17hbf0be45c875f1426E.llvm.15065180575710948936 ()
#24 0x0000555555667b73 in core::ops::function::FnOnce::call_once{{vtable.shim}} ()
#25 0x0000555555b99213 in alloc::boxed::{impl#45}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:1988
#26 alloc::boxed::{impl#45}::call_once<(), alloc::boxed::Box, alloc::alloc::Global>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:1988
#27 std::sys::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/unix/thread.rs:108
#28 0x00007ffff7d8f8fd in start_thread (arg=) at pthread_create.c:442
#29 0x00007ffff7e11a60 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

@joshuataylor
Copy link

tldr: install wasm-pack with --no-default-features to use the system OpenSSL instead of the vendored OpenSSL:

cargo install wasm-pack --no-default-features

Why does this work?

wasm-pack Cargo.toml has this flag:

[features]
# OpenSSL is vendored by default, can use system OpenSSL through feature flag.
default = ['openssl/vendored']

Here is a strace if that helps?

I also tried upgrading OpenSSL in the project to see if that helped (if a backwards incompatible happened recently?), it did not.

I know it uses a vendored OpenSSL, but here's my versions:

$ openssl version
OpenSSL 3.0.7 1 Nov 2022 (Library: OpenSSL 3.0.7 1 Nov 2022)

$ uname -a
Linux kit 6.1.3-1-cachyos-cfs #1 SMP PREEMPT_DYNAMIC Thu, 05 Jan 2023 06:34:32 +0000 x86_64 GNU/Linux

$ rustc --version
rustc 1.68.0-nightly (0fb8b72ce 2023-01-06)

$ cargo 1.68.0-nightly (8c460b223 2023-01-04)

@rongcuid
Copy link

I get this on basically any command:

[ 1832.093684] traps: wasm-pack[37757] general protection fault ip:7f7f949ff068 sp:7f7f9439bf68 error:0 in libcrypto.so.3.0.8[7f7f948ad000+257000]

When I use sys-openssl or no default feature, I get this error:

$ wasm-pack new test-wasm
Error: expected value at line 1 column 1
Caused by: expected value at line 1 column 1

I have openssl 3.0.8 on my Fedora system.

@dullbananas
Copy link

dullbananas commented May 26, 2023

I only have this issue when running wasm-pack on a domcloud server. Here's steps to reproduce:

  1. Log in to https://my.domcloud.co/
  2. Click "add a website"
  3. Click "custom template" and set region to new york
  4. Click "add website"
  5. Wait for "your site is ready" popup and click cancel
  6. Switch to the "manage" tab - might be under "setup"
  7. Click "WebSSH"
  8. Run these commands:
ulimit -c unlimited # allows core dump to be written
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. ~/.cargo/env
cargo install wasm-pack --version 0.11.1 --debug
wget -c https://codeberg.org/dullbananas/font-generator/archive/b8ad551fb5499b7d39218c281f2360461f18a3c3.tar.gz -O - | tar -xz
cd font-generator
sh scripts/release-server.sh

Core dump:
core.wasm-pack.1966.e2510f042fdd40e486156c0baa33c29c.1510496.1685076500000000.zip

--no-default-features fixes it

@ranile ranile mentioned this issue May 30, 2023
3 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants