You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to catch panics in some code with Flume:
pubfnadd_allocation(&self,address:usize,size:usize){// simplified from real code.catch_unwind(|| {self.sender.send(AddAllocationCommand{
address,
size,}.into(),).unwrap_or(());});}
This gives the following error:
error[E0277]: the type `UnsafeCell<flume::Chan<TrackingCommandEnum>>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
--> src/api.rs:359:9
|
359 | catch_unwind(|| {
| ^^^^^^^^^^^^ `UnsafeCell<flume::Chan<TrackingCommandEnum>>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
|
::: /home/itamarst/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:430:40
|
430 | pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
| ---------- required by this bound in `catch_unwind`
|
= help: within `&SendToStateThread`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<flume::Chan<TrackingCommandEnum>>`
= note: required because it appears within the type `spin::mutex::spin::SpinMutex<flume::Chan<TrackingCommandEnum>>`
= note: required because it appears within the type `spin::mutex::Mutex<flume::Chan<TrackingCommandEnum>>`
= note: required because it appears within the type `flume::Shared<TrackingCommandEnum>`
= note: required because it appears within the type `alloc::sync::ArcInner<flume::Shared<TrackingCommandEnum>>`
= note: required because it appears within the type `PhantomData<alloc::sync::ArcInner<flume::Shared<TrackingCommandEnum>>>`
= note: required because it appears within the type `Arc<flume::Shared<TrackingCommandEnum>>`
= note: required because it appears within the type `flume::Sender<TrackingCommandEnum>`
= note: required because it appears within the type `SendToStateThread`
= note: required because it appears within the type `&SendToStateThread`
= note: required because of the requirements on the impl of `UnwindSafe` for `&&SendToStateThread`
= note: required because it appears within the type `[closure@src/api.rs:359:22: 368:10]`
error: aborting due to previous error; 1 warning emitted
Is this actually a problem? I can work around this AssertUnwindSafe... but that's a bad idea if it really isn't unwind safe.
If it is unwind safe, probably the relevant code should have the UnwindSafe trait.
If it is not unwind safe... any suggestions? I need to really really make sure no panics make it out, due to being called from FFI boundary (I don't want to abort the process).
The text was updated successfully, but these errors were encountered:
Hi,
I'm trying to catch panics in some code with Flume:
This gives the following error:
AssertUnwindSafe
... but that's a bad idea if it really isn't unwind safe.UnwindSafe
trait.The text was updated successfully, but these errors were encountered: