Skip to content
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

Consider setting panic to abort in teos #57

Open
sr-gi opened this issue May 18, 2022 · 4 comments
Open

Consider setting panic to abort in teos #57

sr-gi opened this issue May 18, 2022 · 4 comments

Comments

@sr-gi
Copy link
Member

sr-gi commented May 18, 2022

The panic behavior is set to unwind at the moment (default), however, this means that if an async task fails, the daemon may not crash but the task will. This can set the daemon in a weird state where some things are expected to be running but they are not.

An example to this is trying to run the daemon with tor support while the tor connection cannot be stablished:

> ./target/debug/teosd --torsupport
Loading configuration from file
2022-05-16T20:28:27.679Z INFO [teosd] tower_id: 02bd2b759dd8a4fcef0f7d9692c105da8400d5da7942ee039e869fbfb8738ffde4
2022-05-16T20:28:27.683Z INFO [teosd] Last known block: 489b5e533c960d070795bb49cdc9d8dad15aef3414d77449107a84beaeb41020
2022-05-16T20:28:27.690Z INFO [teosd] Bootstrapping from backed up data
2022-05-16T20:28:27.690Z INFO [teosd] Bootstrap completed. Turning on interfaces
2022-05-16T20:28:27.690Z INFO [teosd] Starting up hidden tor service
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: ConnectionRefused, error: Custom { kind: ConnectionRefused, error: "failed to connect to tor control port" } }', teos/src/main.rs:281:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2022-05-16T20:29:11.532Z INFO [teos::api::http] Received get_appointment request from 127.0.0.1:53555
2022-05-16T20:29:11.553Z INFO [teos::api::http] Request failed, error_code=7
2022-05-16T20:29:11.985Z INFO [teos::api::http] Received get_appointment request from 127.0.0.1:53556
2022-05-16T20:29:12.004Z INFO [teos::api::http] Request failed, error_code=7

We should consider changing the panic behavior or making this crash the daemon in some way.

Source: https://users.rust-lang.org/t/panic-in-tokio-task-does-not-end-the-program-execution/45731

@sr-gi
Copy link
Member Author

sr-gi commented May 18, 2022

@tee8z

@booklearner
Copy link
Contributor

In the Cargo.toml file we can configure the program to abort on panic instead by adding:

[profile.release]
panic = 'abort'

I'm not familiar with the entire codebase so I'm not sure if this will cause any other issues, though if it does we probably want to handle those panics differently as well.

Thoughts? I'd be happy to open a PR to fix this.

@sr-gi
Copy link
Member Author

sr-gi commented Jul 28, 2022

@booklearner I'm pretty sure I tried that back in the day but it didn't work. You're more than welcome to give it a go though.

@sr-gi sr-gi added this to the v.0.1.2 milestone Aug 24, 2022
@sr-gi
Copy link
Member Author

sr-gi commented Aug 24, 2022

Keeping an eye on this tokio-rs/tokio#4516

@sr-gi sr-gi removed this from the v.0.1.2 milestone Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants