Fix batched timeout (#1920)
* fix ptr * fix ptr * fix * One less windows warning * One less windows warning
This commit is contained in:
parent
781e830923
commit
1b9f4ea29c
@ -1,21 +1,22 @@
|
|||||||
//! The struct `TimerStruct` will absorb all the difference in timeout implementation in various system.
|
//! The struct `TimerStruct` will absorb all the difference in timeout implementation in various system.
|
||||||
use core::time::Duration;
|
|
||||||
#[cfg(any(windows, target_os = "linux"))]
|
#[cfg(any(windows, target_os = "linux"))]
|
||||||
use core::{
|
use core::ptr::addr_of_mut;
|
||||||
ffi::c_void,
|
use core::time::Duration;
|
||||||
ptr::{addr_of_mut, write_volatile},
|
|
||||||
};
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use core::{
|
use core::{
|
||||||
mem::zeroed,
|
mem::zeroed,
|
||||||
ptr::{self, addr_of, null_mut},
|
ptr::{addr_of, null_mut},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(all(unix, not(target_os = "linux")))]
|
#[cfg(all(unix, not(target_os = "linux")))]
|
||||||
pub(crate) const ITIMER_REAL: core::ffi::c_int = 0;
|
pub(crate) const ITIMER_REAL: core::ffi::c_int = 0;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use core::sync::atomic::{compiler_fence, Ordering};
|
use core::{
|
||||||
|
ffi::c_void,
|
||||||
|
ptr::write_volatile,
|
||||||
|
sync::atomic::{compiler_fence, Ordering},
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use libafl_bolts::current_time;
|
use libafl_bolts::current_time;
|
||||||
@ -29,7 +30,7 @@ use windows::Win32::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(any(windows, target_os = "linux"))]
|
#[cfg(windows)]
|
||||||
use crate::executors::hooks::inprocess::GLOBAL_STATE;
|
use crate::executors::hooks::inprocess::GLOBAL_STATE;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -296,12 +297,6 @@ impl TimerStruct {
|
|||||||
pub fn set_timer(&mut self) {
|
pub fn set_timer(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
if self.batch_mode {
|
if self.batch_mode {
|
||||||
let data = addr_of_mut!(GLOBAL_STATE);
|
|
||||||
write_volatile(
|
|
||||||
addr_of_mut!((*data).executor_ptr),
|
|
||||||
ptr::from_mut(self) as *mut c_void,
|
|
||||||
);
|
|
||||||
|
|
||||||
if self.executions == 0 {
|
if self.executions == 0 {
|
||||||
libc::timer_settime(self.timerid, 0, addr_of_mut!(self.itimerspec), null_mut());
|
libc::timer_settime(self.timerid, 0, addr_of_mut!(self.itimerspec), null_mut());
|
||||||
self.tmout_start_time = current_time();
|
self.tmout_start_time = current_time();
|
||||||
|
@ -5,7 +5,7 @@ use alloc::vec::Vec;
|
|||||||
use core::{
|
use core::{
|
||||||
cell::UnsafeCell,
|
cell::UnsafeCell,
|
||||||
fmt::{self, Display, Formatter},
|
fmt::{self, Display, Formatter},
|
||||||
ptr::{self, addr_of_mut, write_volatile},
|
ptr::{self, addr_of, addr_of_mut, write_volatile},
|
||||||
sync::atomic::{compiler_fence, Ordering},
|
sync::atomic::{compiler_fence, Ordering},
|
||||||
};
|
};
|
||||||
use std::os::raw::{c_long, c_void};
|
use std::os::raw::{c_long, c_void};
|
||||||
@ -463,7 +463,8 @@ pub(crate) unsafe fn setup_ctrl_handler<T: 'static + CtrlHandler>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "system" fn ctrl_handler(ctrl_type: u32) -> BOOL {
|
unsafe extern "system" fn ctrl_handler(ctrl_type: u32) -> BOOL {
|
||||||
match &CTRL_HANDLER {
|
let handler = ptr::read_volatile(addr_of!(CTRL_HANDLER));
|
||||||
|
match handler {
|
||||||
Some(handler_holder) => {
|
Some(handler_holder) => {
|
||||||
info!("{:?}: Handling ctrl {}", std::process::id(), ctrl_type);
|
info!("{:?}: Handling ctrl {}", std::process::id(), ctrl_type);
|
||||||
let handler = &mut *handler_holder.handler.get();
|
let handler = &mut *handler_holder.handler.get();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user