in reverie-ptrace/src/validation.rs [159:191]
fn check_for_ioc_period_bug(precise_ip: bool) -> Result<(), PmuValidationError> {
// Start a cycles counter
let mut attr = ticks_attr(precise_ip);
attr.__bindgen_anon_1.sample_period = 0xffffffff;
attr.set_exclude_callchain_kernel(1);
let bug_fd = start_counter(0, -1, &mut attr, None)?;
let mut new_period = 1_u64;
let _ioctl = ioctl(
&bug_fd,
perf::perf_event_ioctls_PERIOD.into(),
&mut new_period,
)?;
let mut poll_bug_fd = libc::pollfd {
fd: bug_fd.0,
events: libc::POLLIN,
revents: 0,
};
let _poll = Errno::result(unsafe { libc::poll(&mut poll_bug_fd as *mut libc::pollfd, 1, 0) })
.map_err(|errno| PmuValidationError::UnexpectedTestingErrnoError {
errno,
msg: "poll syscall failed in ioc period bug check",
})?;
if poll_bug_fd.revents == 0 {
Err(PmuValidationError::IocPeriodBugDetected)
} else {
Ok(())
}
}