Skip to content

Segmentation fault when initializing tls on 1.51.0-x86_64-unknown-linux-musl #1462

Closed
@seanpianka

Description

@seanpianka

First, add this Dockerfile:

FROM rust:1.51.0-alpine3.12
ADD . /root/bugtest
RUN apk update \
    && apk add --no-cache \
        musl-dev \
        gdb \
        alpine-sdk \
        openssl-dev \
        vim \
    && rustup toolchain add nightly-2021-03-09 \
    && rustup show
RUN cd /root/bugtest \
    && cargo clean \
    && cargo test

Then, create a new binary with $ cargo new bugtest, and add the following contents:
src/main.rs:

#[cfg(test)]
mod tests {
    #[test]
    fn should_not_segfault() {
        let _ = openssl::ssl::SslMethod::tls();
    }
}

Cargo.toml:

[package]
name = "opensslbug"
version = "0.1.0"
authors = ["Sean"]
edition = "2018"

[dependencies]
openssl = "0.10"

Finally, invoke $ docker build -f Dockerfile -t bug:latest . and see the output containing the seg-fault:

Step 4/4 : RUN cd /root/bugtest     && cargo clean     && cargo test
...
...
     Running target/debug/deps/opensslbug-32d8fefb19f1f2a5

running 1 test
error: test failed, to rerun pass '--bin opensslbug'

Caused by:
  process didn't exit successfully: `/root/bugtest/target/debug/deps/opensslbug-32d8fefb19f1f2a5` (signal: 11, SIGSEGV: invalid memory reference)
The command '/bin/sh -c cd /root/bugtest     && cargo clean     && cargo test' returned a non-zero code: 101

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions