Change:
I expected to see this happen: No errors. This code compiles on Linux, as I would expect based on Condvar's documentation. Instead, this happened: When compiling on Mac OS, I get this error: On Linux, this code compiles correctly, and the hosted Rust document this type as UnwindSafe. I'm filing this issue to ask: Is the current MacOS implementation not actually UnwindSafe? My workaround for this issue is to wrap Condvar in AssertUnwindwSafe, but I would like to confirm this is actually safe. My personal hope is that these sync primitives are UnwindSafe and that this is a safe workaround. <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --:
label O-macos T-libs
sounds like a bug, there's probably an implementation missing on some MacOS specific sys struct, the unwind safety traits are always forgotten feel free to send a PR adding it
Hi, is there any updates? I am seeing the same issue.
No updates because no one has fixed this yet. Feel free to make a PR and fix if yourself :)
Is it correct to assume that Condvar is supposed to be UnwindSafe on all platforms? My basic understanding of this is that Condvar should be UnwindSafe and, barring any surprises, the data structures should already be unwind safe and are simply not marked as such. it seems like this issue likely affects multiple platforms, as similar primitives are used across other Condvars without accompanying UnwindSafe impls. I'm happy to try to put together a PR that adds a test asserting unwind safety (similar tests exist for other data structures) if someone more knowledgeable than me can confirm it is the correct thing to do. This would be my first contribution, which is also why I'm hesitant to throw in a PR about something I'm not sure I fully understand.
What's a current state of this bug, please?
said they'd work on here, but nothing seems to have happened. If you want to, you can submit a PR fixing it.
Actually the current state is asking whether it is the correct behavior for all platforms or not. My last comment expressed how I do not have confidence to know that it's the right choice, and was looking for confirmation on the approach before beginning work.
Generally for these platforms, we would really like them all to be the same, otherwise it results in really confusing issues.
I do agree. A condition variable's behavior as a synchronization primitive should be consistent across platforms. If it is on Linux, it should also be on macOS.

Discussion:
use crate::collections; use crate::panicking; use crate::sync::atomic::{AtomicU8, Ordering}; <del> use crate::sync::{Mutex, RwLock}; </del> <ins> use crate::sync::{Condvar, Mutex, RwLock}; </ins> use crate::thread::Result; #[doc(hidden)]

impl<T: ?Sized> UnwindSafe for Mutex<T> {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl<T: ?Sized> UnwindSafe for RwLock<T> {} <ins> #[stable(feature = "catch_unwind", since = "1.9.0")] impl UnwindSafe for Condvar {} </ins> #[stable(feature = "unwind_safe_lock_refs", since = "1.12.0")] impl<T: ?Sized> RefUnwindSafe for Mutex<T> {} #[stable(feature = "unwind_safe_lock_refs", since = "1.12.0")] impl<T: ?Sized> RefUnwindSafe for RwLock<T> {} <ins> #[stable(feature = "unwind_safe_lock_refs", since = "1.12.0")] impl RefUnwindSafe for Condvar {} </ins> // https://github.com/rust-lang/rust/issues/62301 #[stable(feature = "hashbrown", since = "1.36.0")]