diff --git a/boreal/src/matcher/validator/dfa.rs b/boreal/src/matcher/validator/dfa.rs index 0711bd42..66f98c5c 100644 --- a/boreal/src/matcher/validator/dfa.rs +++ b/boreal/src/matcher/validator/dfa.rs @@ -1,3 +1,4 @@ +use std::panic::{RefUnwindSafe, UnwindSafe}; use std::sync::Arc; use regex_automata::hybrid::dfa::{Builder, Cache, DFA}; @@ -11,7 +12,7 @@ use crate::matcher::widener::widen_hir; use crate::matcher::{MatchType, Modifiers}; use crate::regex::{regex_hir_to_string, Hir}; -type PoolCreateFn = Box Cache + Send + Sync>; +type PoolCreateFn = Box Cache + Send + Sync + UnwindSafe + RefUnwindSafe>; #[derive(Debug)] pub(crate) struct DfaValidator { diff --git a/boreal/src/module/mod.rs b/boreal/src/module/mod.rs index 218f3f33..825e6a7a 100644 --- a/boreal/src/module/mod.rs +++ b/boreal/src/module/mod.rs @@ -109,7 +109,7 @@ pub use self::cuckoo::{Cuckoo, CuckooData}; /// /// - As dynamic values, whose shape depend on the memory being scanned. This often includes /// arrays such as `elf.sections`, or raw values such as `pe.machine`. -pub trait Module: Send + Sync { +pub trait Module: Send + Sync + UnwindSafe + RefUnwindSafe { /// Name of the module, used in `import` clauses. fn get_name(&self) -> &'static str; diff --git a/boreal/src/scanner/mod.rs b/boreal/src/scanner/mod.rs index 2aa0c9af..f6db0d24 100644 --- a/boreal/src/scanner/mod.rs +++ b/boreal/src/scanner/mod.rs @@ -882,7 +882,9 @@ impl std::fmt::Display for DefineSymbolError { #[cfg(test)] mod tests { use crate::module::{EvalContext, ScanContext, StaticValue, Type, Value as ModuleValue}; - use crate::test_helpers::{test_type_traits, test_type_traits_non_clonable}; + use crate::test_helpers::{ + test_type_traits, test_type_traits_non_clonable, test_type_unwind_safe, + }; use crate::Compiler; use super::*; @@ -1515,6 +1517,8 @@ mod tests { Vec::new(), BytesPool::default(), )); + test_type_unwind_safe::(); + test_type_traits_non_clonable(ScanResult { matched_rules: Vec::new(), module_values: Vec::new(), diff --git a/boreal/src/test_helpers.rs b/boreal/src/test_helpers.rs index 1f41093b..8a27673c 100644 --- a/boreal/src/test_helpers.rs +++ b/boreal/src/test_helpers.rs @@ -1,3 +1,5 @@ +use std::panic::{RefUnwindSafe, UnwindSafe}; + use boreal_parser::hex_string::parse_hex_string; use boreal_parser::regex::parse_regex; @@ -19,9 +21,11 @@ pub fn expr_to_hir(expr: &str) -> Hir { pub fn test_type_traits(t: T) { #[allow(clippy::redundant_clone)] let _r = t.clone(); - let _r = format!("{:?}", &t); + test_type_traits_non_clonable(t); } pub fn test_type_traits_non_clonable(t: T) { let _r = format!("{:?}", &t); } + +pub fn test_type_unwind_safe() {}