alexcrichton / openssl-src-rs

Source code and logic to build OpenSSL from source
Apache License 2.0
69 stars 114 forks source link

Runtime failure with i686-unknown-linux-musl #86

Open vi opened 3 years ago

vi commented 3 years ago

src/main.rs:

fn main() {
    use openssl::ssl::{SslMethod, SslConnector};
    use std::io::{Read, Write};
    use std::net::TcpStream;

    let mut cb = SslConnector::builder(SslMethod::tls()).unwrap();
    cb.set_verify(openssl::ssl::SslVerifyMode::NONE);
    let connector = cb.build();

    let stream = TcpStream::connect("example.com:443").unwrap();
    let mut stream = connector.connect("example.com", stream).unwrap();

    stream.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap();
    let mut res = vec![];
    stream.read_to_end(&mut res).unwrap();
    println!("{}", String::from_utf8_lossy(&res));
}

Cargo.toml:

[package]
name = "osslvtest"
version = "0.1.0"
authors = []
edition = "2018"

[dependencies]
openssl = { version = "0.10.32", features = ["vendored"] }

Run attempt:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ErrorStack([Error { code: 604422254, library: "random number generator", function: "RAND_DRBG_instantiate", reason: "error retrieving entropy", file: "crypto/rand/drbg_lib.c", line: 335 }, Error { code: 604418162, library: "random number generator", function: "RAND_DRBG_generate", reason: "in error state", file: "crypto/rand/drbg_lib.c", line: 588 }, Error { code: 604422254, library: "random number generator", function: "RAND_DRBG_instantiate", reason: "error retrieving entropy", file: "crypto/rand/drbg_lib.c", line: 335 }, Error { code: 604422254, library: "random number generator", function: "RAND_DRBG_instantiate", reason: "error retrieving entropy", file: "crypto/rand/drbg_lib.c", line: 335 }, Error { code: 604418162, library: "random number generator", function: "RAND_DRBG_generate", reason: "in error state", file: "crypto/rand/drbg_lib.c", line: 588 }, Error { code: 604422254, library: "random number generator", function: "RAND_DRBG_instantiate", reason: "error retrieving entropy", file: "crypto/rand/drbg_lib.c", line: 335 }, Error { code: 604418162, library: "random number generator", function: "RAND_DRBG_generate", reason: "in error state", file: "crypto/rand/drbg_lib.c", line: 588 }, Error { code: 604422254, library: "random number generator", function: "RAND_DRBG_instantiate", reason: "error retrieving entropy", file: "crypto/rand/drbg_lib.c", line: 335 }, Error { code: 604418162, library: "random number generator", function: "RAND_DRBG_generate", reason: "in error state", file: "crypto/rand/drbg_lib.c", line: 588 }, Error { code: 604422254, library: "random number generator", function: "RAND_DRBG_instantiate", reason: "error retrieving entropy", file: "crypto/rand/drbg_lib.c", line: 335 }, Error { code: 604422254, library: "random number generator", function: "RAND_DRBG_instantiate", reason: "error retrieving entropy", file: "crypto/rand/drbg_lib.c", line: 335 }, Error { code: 604418162, library: "random number generator", function: "RAND_DRBG_generate", reason: "in error state", file: "crypto/rand/drbg_lib.c", line: 588 }, Error { code: 604422254, library: "random number generator", function: "RAND_DRBG_instantiate", reason: "error retrieving entropy", file: "crypto/rand/drbg_lib.c", line: 335 }, Error { code: 604418162, library: "random number generator", function: "RAND_DRBG_generate", reason: "in error state", file: "crypto/rand/drbg_lib.c", line: 588 }, Error { code: 336236609, library: "SSL routines", function: "SSL_CTX_new", reason: "malloc failure", file: "ssl/ssl_lib.c", line: 3147 }])', src/main.rs:6:58

Does not happen with non-musl i686 or with x86_64 musl build. arm-unknown-linux-musleabi also works.

Trying with RUSTFLAGS='-C link-arg=-Wl,-z,stack-size=0x1000000' does not lead to improvement.

rustc 1.49.0 (e1884a8e3 2020-12-29), cargo 1.49.0 (d00d64df9 2020-12-05).

DavidSchmidt1 commented 2 years ago

I know this Issue is quite old but in case someone gets to this issue via Google: We had similar issues with this, after some time we found this repos https://github.com/messense/rust-musl-cross which provides docker container ready to use. Since compiling open-ssl for musl is a pain.