-
Notifications
You must be signed in to change notification settings - Fork 62
ZeroNSd segfault in Alpine docker #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What does your script have it it? Also some details about how you built it would be good.
Sent from ProtonMail mobile
…-------- Original Message --------
On Aug 31, 2021, 7:50 AM, Mauro Condarelli wrote:
Disclaimer: I know nothing about Rust, Rust programming, Cargo, Rust and such; this could well be entirely my fault, please be lenient.
I was trying to setup this in a container (FROM rust:alpine), but standard zeronsd start -d <domain> <network-id> simply exited with an uninformative "Segmentation fault" error.
I then made a VirualBox VM with the same content as Docker Container, compiled with debugging symbols and fired-up rust-gdb --args /home/mcondarelli/zeronsd/target/debug/zeronsd start ...
Sure enough I got the same error.
alpine:~# ./start.zeronsd.sh
GNU gdb (GDB)
10
.
2
Copyright (C)
2021
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:
<https://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 /home/mcondarelli/zeronsd/
target
/debug/zeronsd...
(gdb) r
Starting
program
: /home/mcondarelli/zeronsd/
target
/debug/zeronsd start -d <domain> <network-id>
[New LWP
12918
]
Thread
1
"
zeronsd
"
received signal SIGSEGV, Segmentation fault.
0x0000000000000000
in ?? ()
(gdb) bt
#
0 0x0000000000000000 in ?? ()
#
1 0x00007ffff76ffc7a in openssl::ssl::SslMethod::tls () at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/openssl-0.10.35/src/ssl/mod.rs:324
#
2 0x00007ffff76f53c2 in native_tls::imp::TlsConnector::new (builder=0x7ffffffedcc0) at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/native-tls-0.2.7/src/imp/openssl.rs:257
#
3 0x00007ffff76f6c32 in native_tls::TlsConnectorBuilder::build (self=0x7ffffffedcc0) at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/native-tls-0.2.7/src/lib.rs:433
#
4 0x00007ffff75e26e0 in reqwest::connect::Connector::new_default_tls<core::option::Option<std::net::ip::IpAddr>> (http=..., tls=..., proxies=Arc(strong=2, weak=0) = {...}, user_agent=...,
local_addr=<error reading
variable
: Cannot access memory at
address
0x0
>, nodelay=true) at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/reqwest-
0
.
11
.
4
/src/connect.rs:
220
#
5 0x00007ffff75b57ed in reqwest::async_impl::client::ClientBuilder::build (self=...) at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/reqwest-0.11.4/src/async_impl/client.rs:253
#
6 0x00007ffff75b654d in reqwest::async_impl::client::Client::new () at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/reqwest-0.11.4/src/async_impl/client.rs:1088
#
7 0x00007ffff75235cc in zerotier_central_api::apis::configuration::{{impl}}::default () at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/zerotier-central-api-1.0.2/src/apis/configuration.rs:45
#
8 0x00007ffff70603a2 in zeronsd::utils::central_config (token=<error reading variable: Cannot access memory at address 0x5>) at src/utils.rs:21
#
9 0x00007ffff6fc0f36 in zeronsd::start (args=0x7ffff8002e38) at src/main.rs:60
#
10 0x00007ffff6fc4856 in zeronsd::main () at src/main.rs:211
(gdb)
An attempt to follow initialization seems to crash when stepping into /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/native-tls-0.2.7/src/imp/openssl.rs#94 ..> ONCE.call_once(openssl_probe::init_ssl_cert_env_vars);.
What am I doing so wrong?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, [view it on GitHub](#106), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAAET24PHKN5Y3IDSOGRCXDT7TT25ANCNFSM5DEJQPPQ).
Triage notifications on the go with GitHub Mobile for [iOS](https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675) or [Android](https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub).
|
Thanks erikh,
Also build is absolutely basic; first I tried the standard:
then I tried the debug/unoptimized way:
of course then I changed slightly the script to start the right executable:
The whole scripting stuff is because I normally compile as a "normal user", but |
thanks for reporting. this is likely due to libc. strong suggestion to just not use alpine (or any musl-based distribution) until I have some time to settle this.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
…On Tuesday, August 31st, 2021 at 4:02 PM, Mauro Condarelli ***@***.***> wrote:
Thanks erikh,
my script is very basic, just set a few Env variables and start zeronsd:
alpine:~# cat start.zeronsd.sh
#!/bin/sh
export RUSTUP_HOME=/usr/local/rustup
export CARGO_HOME=/usr/local/cargo
export PATH=/usr/local/cargo/bin:$PATH \
export RUST_VERSION=1.54.0
export ZEROTIER_CENTRAL_TOKEN="..."
zeronsd start -d condarelli.it ...
Also build is absolutely basic; first I tried the standard:
cargo install --path .
then I tried the debug/unoptimized way:
cargo build
of course then I changed slightly the script to start the right executable:
...
rust-gdb --args /home/mcondarelli/zeronsd/target/debug/zeronsd start -d condarelli.it ...
The whole scripting stuff is because I normally compile as a "normal user", but zeronsd needs to be "root" to access ZeroTier-One authtoken and other stuff (at least this is how I understood, if I'm wrong please correct me).
—
You are receiving this because you commented.
Reply to this email directly, [view it on GitHub](#106 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAAET25BQRG7CYDBQATIYL3T7VNQDANCNFSM5DEJQPPQ).
Triage notifications on the go with GitHub Mobile for [iOS](https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675) or [Android](https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub).
|
Just to be clear, this is not your failure or fault. This is an incompatibility with some library (likely openssl or libc) and our code. zeronsd needs to run as root to bind on port 53, which is used for DNS. |
after some sleuthing I think I figured out what the problem might be. alexcrichton/openssl-probe#19 If you could do me a favor, ensure one of these paths exist on your system where zeronsd is running? This will help me report / patch the issue. https://github.com/alexcrichton/openssl-probe/blob/master/src/lib.rs#L24 |
Hi,
As you see two of those paths actually exist. |
I'm trying to suss out what is causing the null ptr dereference in your trace. It seems related to the listening address at a second peek, so maybe I jumped the gun on that report, but still, rust should largely prevent this from happening before the project is compiled, so it is almost definitely happening somewhere in the FFI layer. You have the requisite paths and this is probably the wrong tree to be barking up. that said, I cannot build with alpine at all. can you share the build instructions you used? I am adapting the project like so: FROM rust:alpine as buildenv
ARG IS_LOCAL=0
ARG VERSION=main
ARG IS_TAG=0
COPY . /code
WORKDIR /code
RUN apk add openssl pkgconfig
RUN sh cargo-docker.sh
FROM alpine:latest
#RUN apt-get update -qq && apt-get install libssl1.1 ca-certificates -y && apt-get autoclean -y && apt-get clean -y
COPY --from=buildenv /usr/local/cargo/bin/zeronsd /usr/bin/zeronsd
ENTRYPOINT ["/usr/bin/zeronsd"] Compare with our root level dockerfile for reference. It is not building because pkg-config cannot find the headers. I am not an alpine user. |
I am able to build using the attached script ( After that I can get to the segfault with:
|
thanks for preparing this; I'm looking into it now. |
Note: as expected redoing (roughly) the same with Debian-bullseye as base seems to work (at least it doesn't segafault): |
yes, our standard zerotier/zeronsd container is built atop debian. |
so, I'll have to look into the alpine specific need later. it's 4am here. :) I need to get some rest. I'm busy with another project, so until I come up for air this may be stalled. Are you ok with another solution for now? |
Yup! FYI: I'm trying to setup a container with a complete solution for Zerotier/controller/controller-gui and dns. |
FWIW zeronsd's crate (v0.2.4) won't compile in Alpine (v3.15) anymore (zeronsd v0.2.3 compiled fine on Alpine v3.14). I'd paste the error here but now when I try to build it again I get an error about I'll switch to debian as well. Thanks! |
Interesting. I'll look into this tomorrow. Thanks. |
Could you try latest master? I updated the dependencies today; may fix something. |
Doing this:
Gives me the same error as before:
Don't worry about it, if you don't want to spend time investigating. I'm happy to switch to debian. |
this was covered by #116 but I thought I fixed it earlier today. Can you try latest main branch one more time? I just updated it again. |
strange, because the cargo.toml requirements explicitly force it at 2 -- can you `cargo tree` for me and dump it here?
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
…On Tuesday, January 25th, 2022 at 10:57 PM, Alan ***@***.***> wrote:
> this was covered by [#116](#116) but I thought I fixed it earlier today. Can you try latest main branch one more time? I just updated it again.
I'm still hitting the same error. I have [075c824](075c824) from origin/main checked out.
—
Reply to this email directly, [view it on GitHub](#106 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAAET27UOMS5M2EU3OWD57DUX6LMBANCNFSM5DEJQPPQ).
Triage notifications on the go with GitHub Mobile for [iOS](https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675) or [Android](https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub).
You are receiving this because you commented.Message ID: ***@***.***>
|
it's compiling here just fine, btw, which is why I'm stumped. :) |
also I got it booting just fine in alpine. These are the steps I took:
|
I made an alpine dockerfile: #122. PTAL. |
Maybe cargo is caching something I can't find? Here's your info:
|
ok. can you |
I recreated my Alpine VM and did these steps, almost exactly yours:
... and it worked fine. Looks like a caching issue? I have no clue. |
yeah seems like cargo has a bug :( |
So I added a dockerfile in an earlier pull request that I just merged. Those of you who use alpine can either:
However, I think this bug can be closed now. Please feel free to comment if it returns. |
This didn't work, fwiw. I'm not blocked, I'll just toss this VM. Just thought I'd let you know |
FWIW it seems likely this was an earlier reproduction of alexcrichton/openssl-probe#30 / rustsec/advisory-db#2209 / https://www.edgedb.com/blog/c-stdlib-isn-t-threadsafe-and-even-safe-rust-didn-t-save-us |
Disclaimer: I know nothing about Rust, Rust programming, Cargo, Rust and such; this could well be entirely my fault, please be lenient.
I was trying to setup this in a container (FROM rust:alpine), but standard
zeronsd start -d <domain> <network-id>
simply exited with an uninformative "Segmentation fault" error.I then made a VirualBox VM with the same content as Docker Container, compiled with debugging symbols and fired-up
rust-gdb --args /home/mcondarelli/zeronsd/target/debug/zeronsd start ...
Sure enough I got the same error.
An attempt to follow initialization seems to crash when stepping into
/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/native-tls-0.2.7/src/imp/openssl.rs#94
..>ONCE.call_once(openssl_probe::init_ssl_cert_env_vars);
.What am I doing so wrong?
The text was updated successfully, but these errors were encountered: