From 79bf53aaa5f0ca10b327a0ff6ee62aa61b530cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20H=C3=B8rl=C3=BCck=20Berg?= <36937807+henrikhorluck@users.noreply.github.com> Date: Sun, 24 May 2026 13:49:21 +0200 Subject: [PATCH] Fix `Principal topic monitor not initialized` panic Like 1b16d318cc2b75e6973ec99718d2381d11edc1dd, reproduces with `cargo test test_pthread` Fix by using stdlib `println!` to avoid interacting with topicMonitor. Enable `allow-print-in-tests` like with crates/printf, such that there i no deny-warning. --- Cargo.toml | 2 ++ clippy.toml | 1 + src/threads/threads.rs | 6 +++--- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 clippy.toml diff --git a/Cargo.toml b/Cargo.toml index 23a36e14d..478b2c9cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -233,6 +233,8 @@ unused_trait_names = "warn" # In the future, they might change to flag other methods of printing. print_stdout = "deny" print_stderr = "deny" +# usage in tests is fine since it avoids interacting with TopicMonitor +# and is configured in clippy.toml with `allow-print-in-tests` [lints] workspace = true diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 000000000..40b1dda5b --- /dev/null +++ b/clippy.toml @@ -0,0 +1 @@ +allow-print-in-tests = true diff --git a/src/threads/threads.rs b/src/threads/threads.rs index 897d0004b..095958556 100644 --- a/src/threads/threads.rs +++ b/src/threads/threads.rs @@ -458,7 +458,7 @@ struct Context { let made = spawn(move || { ctx2.val.fetch_add(2, Ordering::Release); ctx2.condvar.notify_one(); - printf!("condvar signalled\n"); + println!("condvar signalled"); }); assert!(made); @@ -466,9 +466,9 @@ struct Context { let (_lock, timeout) = ctx .condvar .wait_timeout_while(lock, Duration::from_secs(5), |()| { - printf!("looping with lock held\n"); + println!("looping with lock held"); if ctx.val.load(Ordering::Acquire) != 5 { - printf!("test_pthread: value did not yet reach goal\n"); + println!("test_pthread: value did not yet reach goal"); return true; } false