Git Product home page Git Product logo

Comments (25)

lo48576 avatar lo48576 commented on July 17, 2024 2

Adding openssl = "0.10" dependency and running the code below (in container of #89 (comment)) also results in coredump.

fn main() {
    let _ = openssl::ssl::SslMethod::tls();
}

It seems that something happened during initialization of OpenSSL, which is invoked from startup routine, before running main() the first call to an openssl function with ffi?.

FWIW, changing the line to let _: Option<openssl::ssl::SslMethod> = None; suppresses the segfault. I think it's because openssl is not being initialized in this case.

from cargo-udeps.

lo48576 avatar lo48576 commented on July 17, 2024 2

It seems that this should be solved by upstream (maybe openssl crate).

from cargo-udeps.

est31 avatar est31 commented on July 17, 2024 2

It seems that this should be solved by upstream

Yeah I'd recommend filing a bug about it upstream. Either your distro that provides the openssl package, or the openssl-rs crate's github (it seems to be reproducible with only openssl, right?).

Given that a workaround seems to exist and the bug is in upstream, I'm closing the issue.

Should many more people hit it, I'll consider making a release with features = ["vendored-openssl"]. Until then people can:

  1. fork cargo-udeps
  2. make the change manually
  3. run cargo install --path .

This should fix the issue for them!

from cargo-udeps.

qryxip avatar qryxip commented on July 17, 2024 1

As far as I remember, Cargo built with x86_64-unknown-linux-musl does not work.

from cargo-udeps.

qryxip avatar qryxip commented on July 17, 2024 1

from cargo-udeps.

qryxip avatar qryxip commented on July 17, 2024 1
  • cargo-udeps built with cargo install --locked also segfaults. So the latest curl-sys released last month is probably irrelevant.
  • cargo udeps -h also segfaults, but cargo-udeps with empty fn main() {} does not.

from cargo-udeps.

qryxip avatar qryxip commented on July 17, 2024 1

Shell::new segfaults...?

(edit) Probably caused by libc::isatty No, atty::is works without segfault.

FROM rust:1.50.0-alpine3.12
ADD . /root/cargo-udeps
RUN apk update \
    && apk add --no-cache \
        musl-dev \
        gdb \
        alpine-sdk \
        openssl-dev \
        vim \
    && rustup toolchain add nightly-2021-03-09 \
    && rustup show \
    && cd /root/cargo-udeps \
    && cargo clean \
    && cargo install --debug --path .
/ # export PS1='# '
# cd /root/cargo-udeps
# vim ./src/main.rs
# cat ./src/main.rs
fn main() {
    let _ = cargo::core::shell::Shell::new();
}
# cargo install --debug --path .
  Installing cargo-udeps v0.1.17 (/root/cargo-udeps)
    Updating crates.io index
   Compiling cargo-udeps v0.1.17 (/root/cargo-udeps)
    Finished dev [unoptimized] target(s) in 3.26s
   Replacing /usr/local/cargo/bin/cargo-udeps
    Replaced package `cargo-udeps v0.1.17 (/root/cargo-udeps)` with `cargo-udeps v0.1.17 (/root/cargo-udeps)` (executable `cargo-udeps`)
# cargo-udeps
Segmentation fault (core dumped)
# echo 'fn main() {}' >./src/main.rs
# cargo install --debug --path .
  Installing cargo-udeps v0.1.17 (/root/cargo-udeps)
    Updating crates.io index
   Compiling cargo-udeps v0.1.17 (/root/cargo-udeps)
    Finished dev [unoptimized] target(s) in 0.83s
   Replacing /usr/local/cargo/bin/cargo-udeps
    Replaced package `cargo-udeps v0.1.17 (/root/cargo-udeps)` with `cargo-udeps v0.1.17 (/root/cargo-udeps)` (executable `cargo-udeps`)
# cargo-udeps
# echo $?
0

from cargo-udeps.

est31 avatar est31 commented on July 17, 2024

Which cargo-udeps version are you using? Also could you try to install a debug version of cargo-udeps and obtain a stacktrace (eg using gdb)?

from cargo-udeps.

seanpianka avatar seanpianka commented on July 17, 2024

Hi @est31, thanks for helping out.

  Installing cargo-udeps v0.1.18

and, how do you suggest install a debug version of cargo-udeps? Is there any other way to obtain debugging info?

from cargo-udeps.

qryxip avatar qryxip commented on July 17, 2024

https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-2
https://github.com/rust-lang/cargo/blob/352f82890359c79a2f716a104c5a786ab8e49c7e/.github/workflows/main.yml

from cargo-udeps.

est31 avatar est31 commented on July 17, 2024

@seanpianka cargo install --debug cargo-udeps should do the trick... regarding cargo not working with musl, that's interesting. x86_64-unknown-linux-musl seems to be tier 2. Is cargo available for this platform via rustup? Does that cargo work?

from cargo-udeps.

seanpianka avatar seanpianka commented on July 17, 2024

AFAIK, cargo works just fine with unknown-linux-musl.

$ cargo +nightly install --debug cargo-udeps
...
    Updating crates.io index
 Downloading crates ...
  Downloaded cargo-udeps v0.1.18
  Installing cargo-udeps v0.1.18
...
    Finished dev [unoptimized] target(s) in 58.22s
  Installing /usr/local/cargo/bin/cargo-udeps
   Installed package `cargo-udeps v0.1.18` (executable `cargo-udeps`)
...
$ cargo +nightly udeps --release --all-targets
/bin/bash: line 147:    25 Segmentation fault      (core dumped) cargo +nightly udeps --release --all-targets

from cargo-udeps.

qryxip avatar qryxip commented on July 17, 2024

In my environment, cargo from rustup cannot even run...

uname -a
Linux extreme 5.10.20-1-lts #1 SMP Thu, 04 Mar 2021 12:02:02 +0000 x86_64 GNU/Linuxrustup toolchain add stable-x86_64-unknown-linux-musl
warning: toolchain 'stable-x86_64-unknown-linux-musl' may not be able to run on this system.
warning: If you meant to build software to target that platform, perhaps try `rustup target add x86_64-unknown-linux-musl` instead?
info: syncing channel updates for 'stable-x86_64-unknown-linux-musl'
info: latest update on 2021-02-11, rust version 1.50.0 (cb75ad5db 2021-02-10)
info: downloading component 'cargo'



info: installing component 'rustfmt'

  stable-x86_64-unknown-linux-musl installed - (error reading rustc version)

info: checking for self-updatescargo +stable-x86_64-unknown-linux-musl install cargo-udeps
Error relocating /lib/libgcc_s.so.1: __cpu_indicator_init: symbol not found
Error relocating /lib/libgcc_s.so.1: __cpu_model: symbol not foundrustc +stable-x86_64-unknown-linux-musl --version
Error relocating /lib/libgcc_s.so.1: __cpu_indicator_init: symbol not found
Error relocating /lib/libgcc_s.so.1: __cpu_model: symbol not found

from cargo-udeps.

seanpianka avatar seanpianka commented on July 17, 2024

No clue, it works fine for me.

+ uname -a
Linux runner-h-concurrent-0 5.8.0-7630-generic #32~1606339263~20.10~61c3910-Ubuntu SMP Thu Nov 26 00:10:35 UTC  x86_64 Linux
+ rustup --version
rustup 1.23.1 (2020-11-30)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.50.0 (cb75ad5db 2021-02-10)`
+ cargo --version
cargo 1.50.0 (f04e7fab7 2021-02-04)
+ rustc --version
rustc 1.50.0 (cb75ad5db 2021-02-10)
$ rustup show
Default host: x86_64-unknown-linux-musl
rustup home:  /usr/local/rustup
installed toolchains
--------------------
nightly-x86_64-unknown-linux-musl
1.50.0-x86_64-unknown-linux-musl (default)
active toolchain
----------------
1.50.0-x86_64-unknown-linux-musl (default)
rustc 1.50.0 (cb75ad5db 2021-02-10)
$ cargo install --debug cargo-udeps
...
Finished dev [unoptimized] target(s) in 59.23s
  Installing /usr/local/cargo/bin/cargo-udeps
   Installed package `cargo-udeps v0.1.18` (executable `cargo-udeps`)
$ cargo udeps --release --all-targets
/bin/bash: line 150:    25 Segmentation fault      (core dumped) cargo udeps --release --all-targets

from cargo-udeps.

qryxip avatar qryxip commented on July 17, 2024

Does cargo-udeps built with x86_64-unknown-linux-gnu work?

from cargo-udeps.

qryxip avatar qryxip commented on July 17, 2024

(I'm still trying to build Cargo with x86_64-unknown-linux-musl, and am unable to run it.)

FROM ubuntu:20.04
RUN apt-get update \
  && apt-get install -y curl musl-tools
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -o /tmp/rustup-init \
  && chmod 755 /tmp/rustup-init \
  && /tmp/rustup-init -y --default-host x86_64-unknown-linux-musl --default-toolchain 1.50.0 --profile minimal
root@ac625b5c07b6:/# rustup show
Default host: x86_64-unknown-linux-musl
rustup home:  /root/.rustup

1.50.0-x86_64-unknown-linux-musl (default)
(error reading rustc version)
root@ac625b5c07b6:/# rustc -V
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/librustc_driver-a9e9a2259481e14c.so)
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so)
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/librustc_driver-a9e9a2259481e14c.so: _Unwind_GetRegionStart: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/librustc_driver-a9e9a2259481e14c.so: _Unwind_GetTextRelBase: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/librustc_driver-a9e9a2259481e14c.so: _Unwind_RaiseException: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/librustc_driver-a9e9a2259481e14c.so: _Unwind_SetIP: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/librustc_driver-a9e9a2259481e14c.so: _Unwind_Resume: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/librustc_driver-a9e9a2259481e14c.so: _Unwind_DeleteException: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/librustc_driver-a9e9a2259481e14c.so: _Unwind_Resume_or_Rethrow: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/librustc_driver-a9e9a2259481e14c.so: _Unwind_GetIPInfo: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/librustc_driver-a9e9a2259481e14c.so: _Unwind_GetDataRelBase: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/librustc_driver-a9e9a2259481e14c.so: _Unwind_SetGR: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/librustc_driver-a9e9a2259481e14c.so: _Unwind_GetLanguageSpecificData: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_Resume: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_GetTextRelBase: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_GetDataRelBase: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_GetRegionStart: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_FindEnclosingFunction: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_DeleteException: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_SetGR: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_SetIP: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_GetCFA: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_GetLanguageSpecificData: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_RaiseException: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_GetIP: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_GetIPInfo: symbol not found
Error relocating /root/.rustup/toolchains/1.50.0-x86_64-unknown-linux-musl/lib/libstd-d2918ad39560ef70.so: _Unwind_Backtrace: symbol not found
root@ac625b5c07b6:/# find /usr/lib -name libgcc_s.so.1
/usr/lib/x86_64-linux-gnu/libgcc_s.so.1

from cargo-udeps.

seanpianka avatar seanpianka commented on July 17, 2024

Does cargo-udeps built with x86_64-unknown-linux-gnu work?

gnu is not available for my use-case/environment.

Try:

FROM rust:1.50.0-alpine3.12
RUN apk update \
    && apk add --no-cache \
        musl-dev \
        gdb \
        openssl-dev \
        alpine-sdk
RUN cargo --version \
    && rustup target add x86_64-unknown-linux-musl \
    && rustup toolchain install nightly \
    && cargo install --debug cargo-udeps

Edit: added openssl-dev.

from cargo-udeps.

qryxip avatar qryxip commented on July 17, 2024

I reproduced the segfault with the image. (But openssl-dev seems to be also necessary.)

# On the host OSsudo sysctl kernel.core_pattern='./core'
[sudo] password for ryo:
kernel.core_pattern = ./core
/ # rustup show
Default host: x86_64-unknown-linux-musl
rustup home:  /usr/local/rustup

installed toolchains
--------------------

nightly-x86_64-unknown-linux-musl
1.50.0-x86_64-unknown-linux-musl (default)

active toolchain
----------------

1.50.0-x86_64-unknown-linux-musl (default)
rustc 1.50.0 (cb75ad5db 2021-02-10)

/ # cargo new /root/a && cd $_
     Created binary (application) `/root/a` package
~/a # cargo +nightly udeps --release --no-targets
Segmentation fault (core dumped)
~/a # gdb cargo-udeps ./core.28
GNU gdb (GDB) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from cargo-udeps...
[New LWP 28]
Core was generated by `/usr/local/cargo/bin/cargo-udeps udeps --release --no-targets'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007f8043a87cf9 in ossl_init ()
#2  0x00007f8043a843e3 in Curl_ssl_init ()
#3  0x00007f8043a541fb in global_init ()
#4  0x00007f8043a54251 in curl_global_init ()
#5  0x00007f8043a47b82 in curl::init::init_inner::{{closure}} ()
#6  0x00007f8043a3e177 in std::sync::once::Once::call_once::{{closure}} ()
#7  0x00007f8043ba1042 in std::sync::once::Once::call_inner ()
    at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b//library/std/src/sync/once.rs:420
#8  0x00007f8043a3e0f8 in std::sync::once::Once::call_once ()
#9  0x00007f804298a271 in curl::init::init_inner ()
#10 0x00007f8043bcb6f2 in libc_start_init ()
#11 0x00007f80429b6fa0 in ?? ()
#12 0x00007f8043bcb717 in libc_start_main_stage2 ()
#13 0x00007f8043bcb6fa in libc_start_init ()
#14 0x0000000000000000 in ?? ()

from cargo-udeps.

qryxip avatar qryxip commented on July 17, 2024

Possibly relating to matklad/once_cell#105?

from cargo-udeps.

seanpianka avatar seanpianka commented on July 17, 2024

I've tried installing curl in that image:

INFO[0026] Running: [/bin/sh -c apk update     && apk add --no-cache         bash         jq         make         shellcheck         musl-dev         openssl-dev         python3         py3-pip         nodejs         yarn         zip         vim         curl         gdb         alpine-sdk         tree] 
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
v3.12.4-8-g97a2ead7a3 [http://dl-cdn.alpinelinux.org/alpine/v3.12/main]
v3.12.4-11-g32c4f23765 [http://dl-cdn.alpinelinux.org/alpine/v3.12/community]
OK: 12762 distinct packages available
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/75) Upgrading musl (1.1.24-r8 -> 1.1.24-r10)
(2/75) Installing fakeroot (1.24-r0)
(3/75) Upgrading libcrypto1.1 (1.1.1g-r0 -> 1.1.1j-r0)
(4/75) Upgrading libssl1.1 (1.1.1g-r0 -> 1.1.1j-r0)
...
(13/75) Installing libcurl (7.69.1-r3)
(14/75) Installing curl (7.69.1-r3)
...
(75/75) Installing zip (3.0-r8)
Executing busybox-1.31.1-r16.trigger
Executing ca-certificates-20191127-r2.trigger
OK: 388 MiB in 130 packages

However, I still see the segmentation fault:

$ cargo udeps --release --all-targets
/bin/bash: line 150:    25 Segmentation fault      (core dumped) cargo udeps --release --all-targets

from cargo-udeps.

qryxip avatar qryxip commented on July 17, 2024

Is libc_start_init called before main in Rust? (I'm not familiar with C)

from cargo-udeps.

est31 avatar est31 commented on July 17, 2024

Huh that's interesting... Maybe a bug with the openssl library/bindings then?

from cargo-udeps.

lo48576 avatar lo48576 commented on July 17, 2024

This problem can be worked around by using vendored openssl instead of alpine's one, by cargo = { version = "0.51", features = ["vendored-openssl"] } in Cargo.toml.
By this change, cargo +nightly-2021-03-09 udeps in the conitainer is able to finish successfully.

Note that apk add perl is required to build vendored openssl.

from cargo-udeps.

seanpianka avatar seanpianka commented on July 17, 2024

Hello, I'd like to report this bug upstream, could you help summarize the issue? "Initializing rust openssl v0.10 bindings is seg-faulting on alpine linux-musl?"

from cargo-udeps.

est31 avatar est31 commented on July 17, 2024

@seanpianka the bug you filed upstream looks good! (as someone who didn't reproduce it)

from cargo-udeps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.