Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ pub enum NonHaltingDiagnostic {
effective_failure_ordering: AtomicReadOrd,
},
FileInProcOpened,
SocketAddressResolution {
error: std::io::Error,
},
}

/// Level of Miri specific diagnostics
Expand Down Expand Up @@ -650,6 +653,8 @@ impl<'tcx> MiriMachine<'tcx> {
| WeakMemoryOutdatedLoad { .. } =>
("tracking was triggered here".to_string(), DiagLevel::Note),
FileInProcOpened => ("open a file in `/proc`".to_string(), DiagLevel::Warning),
SocketAddressResolution { .. } =>
("error during socket address resolution".to_string(), DiagLevel::Warning),
};

let title = match &e {
Expand Down Expand Up @@ -698,12 +703,21 @@ impl<'tcx> MiriMachine<'tcx> {
format!("GenMC currently does not model the failure ordering for `compare_exchange`. {was_upgraded_msg}. Miri with GenMC might miss bugs related to this memory access.")
}
FileInProcOpened => format!("files in `/proc` can bypass the Abstract Machine and might not work properly in Miri"),
SocketAddressResolution { .. } => format!("address resolution errors aren't handled properly in Miri")
};

let notes = match &e {
ProgressReport { block_count } => {
vec![note!("so far, {block_count} basic blocks have been executed")]
}
SocketAddressResolution { error } => {
vec![
note!(
"instead of the actual error, Miri just returns a generic protocol error"
),
note!("the actual error is '{error}'"),
]
}
_ => vec![],
};

Expand Down
7 changes: 7 additions & 0 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ pub struct MiriMachine<'tcx> {
/// The list of all EpollEventInterest.
pub(crate) epoll_interests: shims::EpollInterestTable,

/// The set of allocated linked lists with
/// address infos.
pub(crate) address_store: shims::AddressInfoStore,

/// This machine's monotone clock.
pub(crate) monotonic_clock: MonotonicClock,

Expand Down Expand Up @@ -755,6 +759,7 @@ impl<'tcx> MiriMachine<'tcx> {
validation: config.validation,
fds: shims::FdTable::init(config.mute_stdout_stderr),
epoll_interests: shims::EpollInterestTable::new(),
address_store: shims::AddressInfoStore::new(),
dirs: Default::default(),
layouts,
threads,
Expand Down Expand Up @@ -1016,6 +1021,7 @@ impl VisitProvenance for MiriMachine<'_> {
data_race,
alloc_addresses,
fds,
address_store,
blocking_io:_,
epoll_interests:_,
tcx: _,
Expand Down Expand Up @@ -1067,6 +1073,7 @@ impl VisitProvenance for MiriMachine<'_> {
env_vars.visit_provenance(visit);
dirs.visit_provenance(visit);
fds.visit_provenance(visit);
address_store.visit_provenance(visit);
data_race.visit_provenance(visit);
borrow_tracker.visit_provenance(visit);
alloc_addresses.visit_provenance(visit);
Expand Down
2 changes: 1 addition & 1 deletion src/shims/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub mod unwind;
pub use self::files::{FdId, FdTable, FileDescriptionRef};
#[cfg(all(feature = "native-lib", unix))]
pub use self::native_lib::trace::{init_sv, register_retcode_sv};
pub use self::unix::{DirTable, EpollInterestTable};
pub use self::unix::{AddressInfoStore, DirTable, EpollInterestTable};

/// What needs to be done after emulating an item (a shim or an intrinsic) is done.
pub enum EmulateItemResult {
Expand Down
19 changes: 19 additions & 0 deletions src/shims/unix/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,25 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let result = this.shutdown(sockfd, how)?;
this.write_scalar(result, dest)?;
}
"getaddrinfo" => {
let [node, service, hints, res] = this.check_shim_sig(
shim_sig!(extern "C" fn(*const _, *const _, *const _, *mut _) -> i32),
link_name,
abi,
args,
)?;
let result = this.getaddrinfo(node, service, hints, res)?;
this.write_scalar(result, dest)?;
}
"freeaddrinfo" => {
let [res] = this.check_shim_sig(
shim_sig!(extern "C" fn(*mut _) -> ()),
link_name,
abi,
args,
)?;
this.freeaddrinfo(res)?;
}

// Time
"gettimeofday" => {
Expand Down
2 changes: 1 addition & 1 deletion src/shims/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub use self::fd::{EvalContextExt as _, UnixFileDescription};
pub use self::fs::{DirTable, EvalContextExt as _};
pub use self::linux_like::epoll::EpollInterestTable;
pub use self::mem::EvalContextExt as _;
pub use self::socket::EvalContextExt as _;
pub use self::socket::{AddressInfoStore, EvalContextExt as _};
pub use self::sync::EvalContextExt as _;
pub use self::thread::{EvalContextExt as _, ThreadNameResult};
pub use self::virtual_socket::EvalContextExt as _;
Expand Down
Loading