diff options
| author | EightFactorial <29801334+EightFactorial@users.noreply.github.com> | 2024-12-10 14:37:35 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-10 16:37:35 -0600 |
| commit | 2feef494718009dbcb5c62ef1e58c84c36e8bcbf (patch) | |
| tree | 8f2ebbc219c14ca383d3b392c3d03aa90c9bf8ac | |
| parent | 07109964ad8486a9d4caee430ccadf7f7fc3d648 (diff) | |
| download | azalea-drasl-2feef494718009dbcb5c62ef1e58c84c36e8bcbf.tar.xz | |
Disable the `deadlock_detection` feature by default (#195)
* Disable the `deadlock_detection` feature by default
Fixes conflicts with any packages that enable parking_lot's `send_guard` feature
* move testbot deadlock detection to a function and add additional comments
---------
Co-authored-by: mat <git@matdoes.dev>
| -rw-r--r-- | Cargo.lock | 46 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | azalea-client/Cargo.toml | 2 | ||||
| -rw-r--r-- | azalea/Cargo.toml | 5 | ||||
| -rwxr-xr-x | azalea/README.md | 2 | ||||
| -rw-r--r-- | azalea/examples/testbot/main.rs | 51 |
6 files changed, 55 insertions, 53 deletions
@@ -233,7 +233,7 @@ dependencies = [ "rand", "rustc-hash 2.1.0", "serde", - "thiserror 2.0.5", + "thiserror 2.0.6", "tokio", "tracing", "uuid", @@ -253,7 +253,7 @@ dependencies = [ "rsa", "serde", "serde_json", - "thiserror 2.0.5", + "thiserror 2.0.6", "tokio", "tracing", "uuid", @@ -296,7 +296,7 @@ dependencies = [ "byteorder", "serde_json", "simdnbt", - "thiserror 2.0.5", + "thiserror 2.0.6", "tracing", "uuid", ] @@ -351,7 +351,7 @@ dependencies = [ "regex", "reqwest", "simdnbt", - "thiserror 2.0.5", + "thiserror 2.0.6", "tokio", "tracing", "uuid", @@ -406,7 +406,7 @@ dependencies = [ "nohash-hasher", "parking_lot", "simdnbt", - "thiserror 2.0.5", + "thiserror 2.0.6", "tracing", "uuid", ] @@ -485,7 +485,7 @@ dependencies = [ "serde_json", "simdnbt", "socks5-impl", - "thiserror 2.0.5", + "thiserror 2.0.6", "tokio", "tokio-util", "tracing", @@ -537,7 +537,7 @@ dependencies = [ "parking_lot", "rustc-hash 2.1.0", "simdnbt", - "thiserror 2.0.5", + "thiserror 2.0.6", "tracing", ] @@ -857,9 +857,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "num-traits", "serde", @@ -1255,9 +1255,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fixedbitset" @@ -1810,9 +1810,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.167" +version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" [[package]] name = "libloading" @@ -2282,7 +2282,7 @@ dependencies = [ "rustc-hash 2.1.0", "rustls", "socket2", - "thiserror 2.0.5", + "thiserror 2.0.6", "tokio", "tracing", ] @@ -2301,7 +2301,7 @@ dependencies = [ "rustls", "rustls-pki-types", "slab", - "thiserror 2.0.5", + "thiserror 2.0.6", "tinyvec", "tracing", "web-time", @@ -2309,9 +2309,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da" +checksum = "52cd4b1eff68bf27940dd39811292c49e007f4d0b4c357358dc9b0197be6b527" dependencies = [ "cfg_aliases", "libc", @@ -2818,7 +2818,7 @@ dependencies = [ "bytes", "percent-encoding", "serde", - "thiserror 2.0.5", + "thiserror 2.0.6", "tokio", ] @@ -2892,11 +2892,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.5" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643caef17e3128658ff44d85923ef2d28af81bb71e0d67bbfe1d76f19a73e053" +checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47" dependencies = [ - "thiserror-impl 2.0.5", + "thiserror-impl 2.0.6", ] [[package]] @@ -2912,9 +2912,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.5" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "995d0bbc9995d1f19d28b7215a9352b0fc3cd3a2d2ec95c2cadc485cdedbcdde" +checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312" dependencies = [ "proc-macro2", "quote", @@ -73,7 +73,7 @@ sha2 = "0.10.8" simdnbt = "0.6" socks5-impl = "0.5.17" syn = "2.0.90" -thiserror = "2.0.5" +thiserror = "2.0.6" tokio = "1.42.0" tokio-util = "0.7.13" tracing = "0.1.41" diff --git a/azalea-client/Cargo.toml b/azalea-client/Cargo.toml index 1d7de5bf..0cf02e8b 100644 --- a/azalea-client/Cargo.toml +++ b/azalea-client/Cargo.toml @@ -27,7 +27,7 @@ bevy_tasks = { workspace = true } bevy_time = { workspace = true } derive_more = { workspace = true, features = ["deref", "deref_mut"] } minecraft_folder_path = { workspace = true } -parking_lot = { workspace = true, features = ["deadlock_detection"] } +parking_lot = { workspace = true } regex = { workspace = true } reqwest = { workspace = true } simdnbt = { workspace = true } diff --git a/azalea/Cargo.toml b/azalea/Cargo.toml index a658c3a8..63e84f54 100644 --- a/azalea/Cargo.toml +++ b/azalea/Cargo.toml @@ -8,7 +8,7 @@ repository = { workspace = true } [package.metadata.release] pre-release-replacements = [ - { file = "README.md", search = "`azalea = \"[a-z0-9\\.-]+\"`", replace = "`azalea = \"{{version}}\"`" }, + { file = "README.md", search = "`azalea = \"[a-z0-9\\.-]+\"`", replace = "`azalea = \"{{version}}\"`" }, ] [dependencies] @@ -37,7 +37,7 @@ futures = { workspace = true } futures-lite = { workspace = true } nohash-hasher = { workspace = true } num-traits = { workspace = true } -parking_lot = { workspace = true, features = ["deadlock_detection"] } +parking_lot = { workspace = true } priority-queue = { workspace = true } rustc-hash = { workspace = true } serde = { workspace = true, optional = true } @@ -48,6 +48,7 @@ uuid = { workspace = true } [dev-dependencies] criterion = { workspace = true } +parking_lot = { workspace = true, features = ["deadlock_detection"] } rand = { workspace = true } [features] diff --git a/azalea/README.md b/azalea/README.md index e7f52cd6..a135add4 100755 --- a/azalea/README.md +++ b/azalea/README.md @@ -99,7 +99,7 @@ Note: If you get a `SetLoggerError`, it's because you have multiple loggers. Aza ## Deadlocks -If your code is simply hanging, it might be a deadlock. Copy the deadlock block in [`azalea/examples/testbot.rs`](https://github.com/azalea-rs/azalea/blob/main/azalea/examples/testbot/main.rs) to the beginning of your code and it'll print a long backtrace if a deadlock is detected. +If your code is simply hanging, it might be a deadlock. Enable `parking_lot`'s `deadlock_detection` feature and copy the deadlock block in [`azalea/examples/testbot.rs`](https://github.com/azalea-rs/azalea/blob/main/azalea/examples/testbot/main.rs) to the beginning of your code and it'll print a long backtrace if a deadlock is detected. ## Backtraces diff --git a/azalea/examples/testbot/main.rs b/azalea/examples/testbot/main.rs index e7d68d5e..9c8d1085 100644 --- a/azalea/examples/testbot/main.rs +++ b/azalea/examples/testbot/main.rs @@ -14,8 +14,8 @@ mod commands; pub mod killaura; -use std::sync::Arc; use std::time::Duration; +use std::{sync::Arc, thread}; use azalea::brigadier::command_dispatcher::CommandDispatcher; use azalea::ecs::prelude::*; @@ -37,30 +37,7 @@ const PATHFINDER_DEBUG_PARTICLES: bool = false; #[tokio::main] async fn main() { - { - use std::thread; - use std::time::Duration; - - use parking_lot::deadlock; - - // Create a background thread which checks for deadlocks every 10s - thread::spawn(move || loop { - thread::sleep(Duration::from_secs(10)); - let deadlocks = deadlock::check_deadlock(); - if deadlocks.is_empty() { - continue; - } - - println!("{} deadlocks detected", deadlocks.len()); - for (i, threads) in deadlocks.iter().enumerate() { - println!("Deadlock #{i}"); - for t in threads { - println!("Thread Id {:#?}", t.thread_id()); - println!("{:#?}", t.backtrace()); - } - } - }); - } + thread::spawn(deadlock_detection_thread); let account = Account::offline(USERNAME); @@ -85,6 +62,30 @@ async fn main() { .unwrap(); } +/// Runs a loop that checks for deadlocks every 10 seconds. +/// +/// Note that this requires the `deadlock_detection` parking_lot feature to be +/// enabled, which is only enabled in azalea by default when running in debug +/// mode. +fn deadlock_detection_thread() { + loop { + thread::sleep(Duration::from_secs(10)); + let deadlocks = parking_lot::deadlock::check_deadlock(); + if deadlocks.is_empty() { + continue; + } + + println!("{} deadlocks detected", deadlocks.len()); + for (i, threads) in deadlocks.iter().enumerate() { + println!("Deadlock #{i}"); + for t in threads { + println!("Thread Id {:#?}", t.thread_id()); + println!("{:#?}", t.backtrace()); + } + } + } +} + #[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] pub enum BotTask { #[default] |
