Fixup serdeany_autoreg (#2721)

* fixup serdeany_autoreg

* missed a spot

* remove explicit checks in ps1 as this is set by Cargo.toml
This commit is contained in:
Addison Crump 2024-11-24 07:00:54 +01:00 committed by GitHub
parent 959ecb32e9
commit e53dd4e6cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 45 additions and 36 deletions

View File

@ -891,6 +891,7 @@ where
min_input_size: self.min_input_size,
max_input_size: self.max_input_size,
timeout,
#[cfg(feature = "regex")]
asan_obs: self
.asan_obs
.clone()
@ -956,6 +957,7 @@ where
min_input_size: self.min_input_size,
max_input_size: self.max_input_size,
timeout,
#[cfg(feature = "regex")]
asan_obs: self
.asan_obs
.clone()
@ -1003,7 +1005,7 @@ where
0,
self.is_persistent,
self.is_deferred_frksrv,
self.asan_obs.is_some(),
self.has_asan_obs(),
self.map_size,
self.debug_child,
self.kill_signal.unwrap_or(KILL_SIGNAL_DEFAULT),
@ -1456,6 +1458,18 @@ where
self.kill_signal = Some(kill_signal);
self
}
/// Determine if the asan observer is present (always false if feature "regex" is disabled)
#[cfg(feature = "regex")]
pub fn has_asan_obs(&self) -> bool {
self.asan_obs.is_some()
}
/// Determine if the asan observer is present (always false if feature "regex" is disabled)
#[cfg(not(feature = "regex"))]
pub fn has_asan_obs(&self) -> bool {
false
}
}
impl<'a> ForkserverExecutorBuilder<'a, NopTargetBytesConverter<BytesInput>, UnixShMemProvider> {
@ -1485,6 +1499,7 @@ impl<'a> ForkserverExecutorBuilder<'a, NopTargetBytesConverter<BytesInput>, Unix
min_input_size: MIN_INPUT_SIZE_DEFAULT,
kill_signal: None,
timeout: None,
#[cfg(feature = "regex")]
asan_obs: None,
crash_exitcode: None,
target_bytes_converter: NopTargetBytesConverter::new(),
@ -1517,6 +1532,7 @@ impl<'a, TC> ForkserverExecutorBuilder<'a, TC, UnixShMemProvider> {
min_input_size: self.min_input_size,
kill_signal: self.kill_signal,
timeout: self.timeout,
#[cfg(feature = "regex")]
asan_obs: self.asan_obs,
crash_exitcode: self.crash_exitcode,
target_bytes_converter: self.target_bytes_converter,
@ -1549,6 +1565,7 @@ impl<'a, TC, SP> ForkserverExecutorBuilder<'a, TC, SP> {
min_input_size: self.min_input_size,
kill_signal: self.kill_signal,
timeout: self.timeout,
#[cfg(feature = "regex")]
asan_obs: self.asan_obs,
crash_exitcode: self.crash_exitcode,
target_bytes_converter,

View File

@ -9,12 +9,10 @@ use std::{cell::RefCell, collections::VecDeque, fmt::Debug, marker::PhantomData,
use libafl_bolts::Error;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
#[cfg(not(miri))]
use crate::inputs::BytesInput;
use crate::{
corpus::Corpus,
executors::{Executor, HasObservers, HasTimeout},
inputs::UsesInput,
inputs::{BytesInput, UsesInput},
observers::ObserversTuple,
stages::Stage,
state::{HasCorpus, State, UsesState},

View File

@ -825,6 +825,26 @@ macro_rules! create_register {
($struct_type:ty) => {};
}
/// Manually register a `SerdeAny` type in the [`RegistryBuilder`]
///
/// Do nothing with the `serdeany_autoreg` feature, as this will be previously registered by ctor.
#[cfg(all(feature = "serdeany_autoreg", not(miri)))]
#[macro_export]
macro_rules! create_manual_register {
($struct_type:ty) => {};
}
/// Manually register a `SerdeAny` type in the [`RegistryBuilder`]
///
/// Do nothing with the `serdeany_autoreg` feature, as this will be previously registered by ctor.
#[cfg(not(all(feature = "serdeany_autoreg", not(miri))))]
#[macro_export]
macro_rules! create_manual_register {
($struct_type:ty) => {
$crate::serdeany::RegistryBuilder::register::<$struct_type>();
};
}
/// Implement a [`SerdeAny`], registering it in the [`RegistryBuilder`] when on std
#[macro_export]
macro_rules! impl_serdeany {
@ -853,7 +873,6 @@ macro_rules! impl_serdeany {
}
}
#[cfg(any(not(feature = "serdeany_autoreg"), miri))]
impl< $( $lt $( : $clt $(+ $dlt )* )? ),+ > $struct_name < $( $lt ),+ > {
/// Manually register this type at a later point in time
@ -861,7 +880,9 @@ macro_rules! impl_serdeany {
/// # Safety
/// This may never be called concurrently as it dereferences the `RegistryBuilder` without acquiring a lock.
pub unsafe fn register() {
$crate::serdeany::RegistryBuilder::register::<$struct_name < $( $lt ),+ >>();
$(
$crate::create_manual_register!($struct_name < $( $opt ),+ >);
)*
}
}
@ -894,7 +915,6 @@ macro_rules! impl_serdeany {
}
}
#[cfg(any(not(feature = "serdeany_autoreg"), miri))]
impl $struct_name {
/// Manually register this type at a later point in time
///
@ -902,7 +922,7 @@ macro_rules! impl_serdeany {
/// This may never be called concurrently as it dereferences the `RegistryBuilder` without acquiring a lock.
#[allow(unused)]
pub unsafe fn register() {
$crate::serdeany::RegistryBuilder::register::<$struct_name>();
$crate::create_manual_register!($struct_name);
}
}

View File

@ -17,20 +17,7 @@ function Run-Clippy {
try {
$env:RUST_BACKTRACE = "full"
cargo +nightly clippy --all-features --no-deps --tests --examples --benches -- -Z macro-backtrace `
-D clippy::all `
-D clippy::pedantic `
-W clippy::similar_names `
-A clippy::type_repetition_in_bounds `
-A clippy::missing-errors-doc `
-A clippy::cast-possible-truncation `
-A clippy::used-underscore-binding `
-A clippy::ptr-as-ptr `
-A clippy::missing-panics-doc `
-A clippy::missing-docs-in-private-items `
-A clippy::unseparated-literal-suffix `
-A clippy::module-name-repetitions `
-A clippy::unreadable-literal
cargo +nightly clippy --all-features --no-deps --tests --examples --benches -- -Z macro-backtrace
# Exit unsuccessfully on clippy error
if (!$?) {
@ -68,20 +55,7 @@ else {
# First run it on all default members
$env:RUST_BACKTRACE = "full"
cargo +nightly clippy --all-features --no-deps --tests --examples --benches -- -Z macro-backtrace `
-D clippy::all `
-D clippy::pedantic `
-W clippy::similar_names `
-A clippy::type_repetition_in_bounds `
-A clippy::missing-errors-doc `
-A clippy::cast-possible-truncation `
-A clippy::used-underscore-binding `
-A clippy::ptr-as-ptr `
-A clippy::missing-panics-doc `
-A clippy::missing-docs-in-private-items `
-A clippy::unseparated-literal-suffix `
-A clippy::module-name-repetitions `
-A clippy::unreadable-literal
cargo +nightly clippy --all-features --no-deps --tests --examples --benches -- -Z macro-backtrace
# Exit unsuccessfully on clippy error
if (!$?) {