https://linen.dev logo
Getting segmentation fault after upgrading to Rust...
# help
l
I just upgraded to Rust 1.65.0 and my fairly new shuttle app is now giving me this error when I try to `cargo shuttle run`:
Copy code
Error: IO error: [1]    32693 segmentation fault  cargo shuttle run
Is this a known issue? Has anyone else encountered this and maybe solved it? *Note that downgrading to
1.64.0
fixes the issue.
k
Hey dp! We had an issue with segfaults a while ago, which was fixed by in 0.7.2: . This one is new, but I have seen it in one other user (they haven't tried to downgrade to fix it yet). We'll take a closer look at this in the coming week. Would you mind sharing your
Cargo.toml
, so we can get an idea of which crates are involved?
l
@kind-area-3810 Thanks for the reply and information! My project does involve other crates but the issue is reliably reproducible just using Rust 1.65.0 and then running these commands:
Copy code
cargo shuttle init --axum
cargo shuttle run
I haven't tried other
init
options. This is blocking my project right now as I need to use a crate that uses Rust 1.65.0. Thanks!
* Note that I'm on an Intel MacbookPro Update: I tried on an M1 MacbookPro and it works šŸ¤”
k
That's strange, I can't reproduce it currently (intel ubuntu):
The other user who reported something similar was on ubuntu as well, though.
The plot thickens!
Oh, by the way, our containers are pinned to 1.63 currently, so that's gonna be another blocker for you. šŸ˜”
We do plan to upgrade of course, but I can't give an ETA on that right now.
s
My service segfaults during
cargo shuttle run
on both Rust 1.65 and 1.63 😦
k
Hey Czar, does this also happen when you run an example (or just a basic cargo shuttle init), or just for your own project? Also what OS are you running on?
s
@kind-area-3810 Hi!
Copy code
bash
cargo shuttle init
cargo shuttle run
> Error: failed to find the shuttle entrypoint.
Copy code
bash
cargo shuttle init --axum
cargo shuttle run
Results in some dependency version error.
Copy code
bash
cargo shuttle init --serenity
# create Secrets.toml with a `BOT_TOKEN`
cargo shuttle run
Results in
Copy code
text
error[E0432]: unresolved import `sha1`
  --> /home/czar/.cargo/registry/src/github.com-1ecc6299db9ec823/tungstenite-0.17.3/src/handshake/mod.rs:15:5
   |
15 | use sha1::{Digest, Sha1};
   |     ^^^^ use of undeclared crate or module `sha1`
   |
help: there is a crate or module with a similar name
   |
15 | use sha_1::{Digest, Sha1};
   |     ~~~~~
error[E0432]: unresolved import `sha1`
  --> /home/czar/.cargo/registry/src/github.com-1ecc6299db9ec823/tungstenite-0.17.3/src/handshake/mod.rs:15:5
   |
15 | use sha1::{Digest, Sha1};
   |     ^^^^ use of undeclared crate or module `sha1`
   |
help: there is a crate or module with a similar name
   |
15 | use sha_1::{Digest, Sha1};
   |     ~~~~~
I'm stumped šŸ˜…
k
Ah, I just stumbled on this one myself, there was an accidental breaking release:
It should be fixed soon šŸ¤ž , but you can test around it by pinning the crate to prev version
I see they are fixing it as we speak
s
@kind-area-3810 I was able to test the panic on a clean serenity project, it does still happen:
Copy code
text
; cargo +1.63 shuttle init --serenity
     Created library (shuttle) package
; cargo +1.63 --locked shuttle run   
Building /home/czar/work/rust/segf
-- snip --
   Compiling segf-00000000-0000-0000-0000-000000000000 v0.1.0 (/home/czar/work/rust/segf)
    Finished dev [unoptimized + debuginfo] target(s) in 51.75s

Starting segf on http://127.0.0.1:8000
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/czar/.cargo/registry/src/github.com-1ecc6299db9ec823/shuttle-service-0.7.2/src/lib.rs:441:66
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Panic occurred in shuttle_service::main`: called `Option::unwrap()` on a `None` value
k
Hmm, is the unwrap in your code?
s
There isn't, I have several calls to
anyhow::context
though. For example:
Copy code
rust
let token = secret_store
    .get("discord-token")
    .context("'discord-token' was not found")?;
k
Hmm, strange, for me it starts and only fails because of missing discord token:
Copy code
Compiling serenity-unwrap-00000000-0000-0000-0000-000000000000 v0.1.0 (/home/oddgrd/dev/experiments/serenity-unwrap)
    Finished dev [unoptimized + debuginfo] target(s) in 39.24s

Starting serenity-unwrap on http://127.0.0.1:8000
Error: Custom error: 'DISCORD_TOKEN' was not found

Caused by:
    'DISCORD_TOKEN' was not found
s
In my case it is not the example project it's a complete, albeit simple, bot, maybe something I added messes with it, but given the error message, I don't know how to find the culprit
k
Do you have a public repo for this by any chance?
s
it's not public, but I can invite you
done
k
It does actually start for me, just errors on invalid token:
Copy code
āÆ cargo shuttle run
Building /home/oddgrd/dev/experiments/rorschach
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s

Starting rorschach on http://127.0.0.1:8000
2022-12-01T12:51:47.559159650Z  INFO serenity::client::bridge::gateway::shard_manager: Telling shard queuer to start shard 0
2022-12-01T12:51:47.798318134Z  INFO serenity::client::bridge::gateway::shard_runner: [ShardRunner [0, 1]] Running
2022-12-01T12:51:47.959883534Z ERROR serenity::gateway::shard: [Shard [0, 1]] Sent invalid authentication, please check the token.
2022-12-01T12:51:47.959946571Z ERROR serenity::client::bridge::gateway::shard_runner: Shard handler received err: Gateway(InvalidAuthentication)
2022-12-01T12:51:47.960091384Z  INFO serenity::client::bridge::gateway::shard_manager: Shutting down all shards
2022-12-01T12:51:47.960123384Z  INFO serenity::client::bridge::gateway::shard_manager: Shutting down shard 0
2022-12-01T12:51:47.960186705Z  INFO serenity::client::bridge::gateway::shard_queuer: Shutting down shard 0
2022-12-01T12:51:47.960206175Z  WARN serenity::client::bridge::gateway::shard_queuer: Failed to cleanly shutdown shard 0 when sending message to shard runner: TrySendError { kind: Disconnected }
2022-12-01T12:51:52.961246436Z  WARN serenity::client::bridge::gateway::shard_manager: Failed to cleanly shutdown shard 0, reached timeout: Elapsed(())
Error: Custom error: failed to bind service

Caused by:
    0: failed to bind service
    1: Custom error: Sent invalid authentication
    2: Sent invalid authentication
    3: Sent invalid authentication
I'm on ubuntu 22 x86 btw and rust 1.65
Copy code
āÆ cargo shuttle --version
cargo-shuttle 0.7.2
To be exact: I cloned the repo, added the secrets with dummy data, and then ran it
s
I'm using rust 1.63, to eliminate it as a variable between local and "prod".
Copy code
text
; uname -a 
Linux home.localnet 6.0.8-1-default #1 SMP PREEMPT_DYNAMIC Fri Nov 11 08:02:50 UTC 2022 (1579d93) x86_64 x86_64 x86_64 GNU/Linux

; cargo shuttle --version             
cargo-shuttle 0.7.2

; cargo version --verbose 
cargo 1.63.0 (fd9c4297c 2022-07-01)
release: 1.63.0
commit-hash: fd9c4297ccbee36d39e9a79067edab0b614edb5a
commit-date: 2022-07-01
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:OpenSSL/1.1.1n)
os: openSUSE 20221129 [64-bit]
So, since you can't reproduce it on your machine, what can I do on my end? I've already tried
cargo clean
, in case there was something stale in the target.
@kind-area-3810 I've updated the repo with some local things that weren't committed/pushed before.
k
I tried running it on 1.63 now and I'm getting an error from loading the secrets, I don't know why yet šŸ˜…
s
also I tried running without Secrets.toml, there was no difference, so it doesn't even reach that part of the code on my side.
Another "btw": I'm pinning to 1.63 via rust-toolchain.toml, it's in the latest commit in the repo
k
I can't seem to avoid the secret error when trying to run this on 1.63, would you mind trying 1.65?
s
hmm, works on 1.65, it didn't before (several days ago)...
k
It is strange indeed, I don't have an explanation for it yet, but I'll try to keep it in mind. We are upgrading our pinned version to 1.65 soon, btw
s
So, it looks like I should just wait for 1.64 or 1.65 upgrade PR to be merged in shuttle. Meanwhile I can continue working locally with 1.65 And also wait while deployment thing gets fixed: https://discord.com/channels/803236282088161321/1046442169742925925/1046442169742925925
k
Yeah. Thank you for your patience!
s
Public beta is public beta, I'm happy to contribute, be it patience, issues, or anything else I have on hand šŸ™‚