Skip to content
Snippets Groups Projects
Commit 08e0fd81 authored by Kornel Lesiński's avatar Kornel Lesiński Committed by Kornel Lesiński
Browse files

GlobalContext is not affected by panics

It has plenty of thread-safety problems, but not this one
parent 2862ad02
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,8 @@ use std::ffi::CStr;
use std::os::raw::c_void;
use std::cell::UnsafeCell;
use std::collections::HashMap;
use std::panic::UnwindSafe;
use std::panic::RefUnwindSafe;
/// A special case for non-thread-aware functions.
///
......@@ -14,6 +16,9 @@ pub struct GlobalContext {
_not_thread_safe: UnsafeCell<YouMustUseThreadContextToShareBetweenThreads>,
}
impl UnwindSafe for GlobalContext {}
impl RefUnwindSafe for GlobalContext {}
#[doc(hidden)]
pub trait Context {
fn as_ptr(&self) -> ffi::Context;
......
......@@ -530,3 +530,11 @@ fn bad_icc() {
let err = Profile::new_icc(&[1, 2, 3]);
assert!(err.is_err());
}
#[test]
fn unwind_safety() {
let ref profile = Profile::new_xyz();
std::panic::catch_unwind(|| {
profile.clone()
}).unwrap();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment