From aaa6de7905b4e5a9d194b8eb6810761861d4280a Mon Sep 17 00:00:00 2001 From: Ophir LOJKINE Date: Fri, 3 Sep 2021 12:14:55 +0200 Subject: [PATCH 1/3] Add a better error message for #39364 There is a known bug in the implementation of mpsc channels in rust. This adds a clearer error message when the bug occurs, so that developers don't lose too much time looking for the origin of the bug. See https://github.com/rust-lang/rust/issues/39364 --- library/std/src/sync/mpsc/shared.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sync/mpsc/shared.rs b/library/std/src/sync/mpsc/shared.rs index 0c32e636a5633..d4ee1b414d9b0 100644 --- a/library/std/src/sync/mpsc/shared.rs +++ b/library/std/src/sync/mpsc/shared.rs @@ -248,7 +248,7 @@ impl Packet { // Returns true if blocking should proceed. fn decrement(&self, token: SignalToken) -> StartResult { unsafe { - assert_eq!(self.to_wake.load(Ordering::SeqCst), 0); + assert_eq!(self.to_wake.load(Ordering::SeqCst), 0, "This is a known bug in rust. See https://github.com/rust-lang/rust/issues/39364"); let ptr = token.cast_to_usize(); self.to_wake.store(ptr, Ordering::SeqCst); From f63096e4f2a08e80eaa4d564946d4fa4d363fc44 Mon Sep 17 00:00:00 2001 From: lovasoa Date: Sun, 5 Sep 2021 22:55:56 +0100 Subject: [PATCH 2/3] rust fmt --- library/std/src/sync/mpsc/shared.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/std/src/sync/mpsc/shared.rs b/library/std/src/sync/mpsc/shared.rs index d4ee1b414d9b0..619a79f437b8a 100644 --- a/library/std/src/sync/mpsc/shared.rs +++ b/library/std/src/sync/mpsc/shared.rs @@ -248,7 +248,11 @@ impl Packet { // Returns true if blocking should proceed. fn decrement(&self, token: SignalToken) -> StartResult { unsafe { - assert_eq!(self.to_wake.load(Ordering::SeqCst), 0, "This is a known bug in rust. See https://github.com/rust-lang/rust/issues/39364"); + assert_eq!( + self.to_wake.load(Ordering::SeqCst), + 0, + "This is a known bug in rust. See https://github.com/rust-lang/rust/issues/39364" + ); let ptr = token.cast_to_usize(); self.to_wake.store(ptr, Ordering::SeqCst); From 598e5b27beef291c016c13f4dfaf724350f37fce Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 22 Sep 2021 20:20:33 +0200 Subject: [PATCH 3/3] Update library/std/src/sync/mpsc/shared.rs --- library/std/src/sync/mpsc/shared.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sync/mpsc/shared.rs b/library/std/src/sync/mpsc/shared.rs index 619a79f437b8a..8487a5f8b50d3 100644 --- a/library/std/src/sync/mpsc/shared.rs +++ b/library/std/src/sync/mpsc/shared.rs @@ -251,7 +251,7 @@ impl Packet { assert_eq!( self.to_wake.load(Ordering::SeqCst), 0, - "This is a known bug in rust. See https://github.com/rust-lang/rust/issues/39364" + "This is a known bug in the Rust standard library. See https://github.com/rust-lang/rust/issues/39364" ); let ptr = token.cast_to_usize(); self.to_wake.store(ptr, Ordering::SeqCst);