Auto merge of #131036 - RalfJung:miri-sync, r=RalfJung

Miri subtree update

r? `@ghost`
This commit is contained in:
bors 2024-09-30 03:16:29 +00:00
commit e9df22f51d
128 changed files with 606 additions and 479 deletions

View File

@ -424,9 +424,9 @@ dependencies = [
[[package]]
name = "chrono-tz"
version = "0.9.0"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb"
checksum = "cd6dd8046d00723a59a2f8c5f295c515b9bb9a331ee4f8f3d4dd49e428acd3b6"
dependencies = [
"chrono",
"chrono-tz-build",
@ -435,12 +435,11 @@ dependencies = [
[[package]]
name = "chrono-tz-build"
version = "0.3.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1"
checksum = "e94fea34d77a245229e7746bd2beb786cd2a896f306ff491fb8cecb3074b10a7"
dependencies = [
"parse-zoneinfo",
"phf",
"phf_codegen",
]

View File

@ -12,9 +12,6 @@ on:
schedule:
- cron: '44 4 * * *' # At 4:44 UTC every day.
permissions:
contents: write
defaults:
run:
shell: bash
@ -90,6 +87,11 @@ jobs:
cron-fail-notify:
name: cronjob failure notification
runs-on: ubuntu-latest
permissions:
# The cronjob needs to be able to push to the repo...
contents: write
# ... and create a PR.
pull-requests: write
needs: [build, style]
if: github.event_name == 'schedule' && failure()
steps:

View File

@ -137,9 +137,12 @@ dependencies = [
[[package]]
name = "cc"
version = "1.1.7"
version = "1.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc"
checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0"
dependencies = [
"shlex",
]
[[package]]
name = "cfg-if"
@ -164,9 +167,9 @@ dependencies = [
[[package]]
name = "chrono-tz"
version = "0.9.0"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb"
checksum = "cd6dd8046d00723a59a2f8c5f295c515b9bb9a331ee4f8f3d4dd49e428acd3b6"
dependencies = [
"chrono",
"chrono-tz-build",
@ -175,12 +178,11 @@ dependencies = [
[[package]]
name = "chrono-tz-build"
version = "0.3.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1"
checksum = "e94fea34d77a245229e7746bd2beb786cd2a896f306ff491fb8cecb3074b10a7"
dependencies = [
"parse-zoneinfo",
"phf",
"phf_codegen",
]
@ -947,6 +949,12 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "siphasher"
version = "0.3.11"

View File

@ -25,7 +25,7 @@ aes = { version = "0.8.3", features = ["hazmat"] }
measureme = "11"
ctrlc = "3.2.5"
chrono = { version = "0.4.38", default-features = false }
chrono-tz = "0.9"
chrono-tz = "0.10"
directories = "5"
# Copied from `compiler/rustc/Cargo.toml`.

View File

@ -219,7 +219,7 @@ degree documented below):
- `solaris` / `illumos`: maintained by @devnexen. Supports `std::{env, thread, sync}`, but not `std::fs`.
- `freebsd`: **maintainer wanted**. Supports `std::env` and parts of `std::{thread, fs}`, but not `std::sync`.
- `android`: **maintainer wanted**. Support very incomplete, but a basic "hello world" works.
- `wasm`: **maintainer wanted**. Support very incomplete, not even standard output works, but an empty `main` function works.
- `wasi`: **maintainer wanted**. Support very incomplete, not even standard output works, but an empty `main` function works.
- For targets on other operating systems, Miri might fail before even reaching the `main` function.
However, even for targets that we do support, the degree of support for accessing platform APIs

View File

@ -41,9 +41,12 @@ dependencies = [
[[package]]
name = "cc"
version = "1.0.73"
version = "1.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0"
dependencies = [
"shlex",
]
[[package]]
name = "cfg-if"
@ -92,3 +95,9 @@ name = "rustc-demangle"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"

View File

@ -1,8 +1,9 @@
//! Extracted from the backtrace crate's test test_frame_conversion
use backtrace::{Backtrace, BacktraceFrame};
use std::fmt::Write;
use backtrace::{Backtrace, BacktraceFrame};
fn main() {
let mut frames = vec![];
backtrace::trace(|frame| {

File diff suppressed because one or more lines are too long

View File

@ -190,9 +190,9 @@ dependencies = [
[[package]]
name = "rustc-build-sysroot"
version = "0.5.3"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2471f8f296262437d7e848e527b4210b44a96e53a3b4435b890227ce3e6da106"
checksum = "d6d984a9db43148467059309bd1e5ad577085162f695d9fe2cf3543aeb25cd38"
dependencies = [
"anyhow",
"rustc_version",

View File

@ -18,7 +18,7 @@ directories = "5"
rustc_version = "0.4"
serde_json = "1.0.40"
cargo_metadata = "0.18.0"
rustc-build-sysroot = "0.5.3"
rustc-build-sysroot = "0.5.4"
# Enable some feature flags that dev-dependencies need but dependencies
# do not. This makes `./miri install` after `./miri build` faster.

View File

@ -8,7 +8,8 @@ use std::{env, thread};
use rustc_version::VersionMeta;
use crate::{setup::*, util::*};
use crate::setup::*;
use crate::util::*;
const CARGO_MIRI_HELP: &str = r"Runs binary crates and tests in Miri
@ -666,6 +667,8 @@ pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: Runner
match phase {
RunnerPhase::Rustdoc => {
cmd.stdin(std::process::Stdio::piped());
// the warning is wrong, we have a `wait` inside the `scope` closure.
#[expect(clippy::zombie_processes)]
let mut child = cmd.spawn().expect("failed to spawn process");
let child_stdin = child.stdin.take().unwrap();
// Write stdin in a background thread, as it may block.

View File

@ -148,18 +148,18 @@ case $HOST_TARGET in
TEST_TARGET=arm-unknown-linux-gnueabi run_tests
TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture of choice
# Partially supported targets (tier 2)
BASIC="empty_main integer vec string btreemap hello hashmap heap_alloc align" # ensures we have the basics: stdout/stderr, system allocator, randomness (for HashMap initialization)
UNIX="panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there
TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname pthread time fs
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname pthread time fs
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX thread sync available-parallelism time tls
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX thread sync available-parallelism time tls
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX pthread --skip threadname --skip pthread_cond_timedwait
TEST_TARGET=wasm32-wasip2 run_tests_minimal empty_main wasm heap_alloc libc-mem
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal empty_main wasm
BASIC="empty_main integer heap_alloc libc-mem vec string btreemap" # ensures we have the basics: pre-main code, system allocator
UNIX="hello panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there
TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC $UNIX time hashmap random threadname pthread fs
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX time hashmap random threadname pthread fs
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX time hashmap random thread sync available-parallelism tls
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX time hashmap random thread sync available-parallelism tls
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap pthread --skip threadname
TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
# Custom target JSON file
TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std
TEST_TARGET=tests/x86_64-unknown-kernel.json MIRI_NO_STD=1 run_tests_minimal no_std
;;
i686-pc-windows-msvc)
# Host

View File

@ -8,12 +8,6 @@ version = "1.0.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.2"
@ -112,13 +106,12 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]]
name = "libredox"
version = "0.0.1"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8"
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
dependencies = [
"bitflags 2.4.2",
"bitflags",
"libc",
"redox_syscall",
]
[[package]]
@ -150,12 +143,6 @@ dependencies = [
"xshell",
]
[[package]]
name = "once_cell"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "option-ext"
version = "0.2.0"
@ -186,20 +173,11 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "redox_syscall"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "redox_users"
version = "0.4.4"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4"
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
dependencies = [
"getrandom",
"libredox",
@ -221,7 +199,7 @@ version = "0.38.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
dependencies = [
"bitflags 2.4.2",
"bitflags",
"errno",
"libc",
"linux-raw-sys",
@ -342,47 +320,25 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "which"
version = "4.4.2"
version = "6.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f"
dependencies = [
"either",
"home",
"once_cell",
"rustix",
"winsafe",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.6"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"winapi",
"windows-sys 0.52.0",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.48.0"
@ -522,6 +478,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winsafe"
version = "0.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"
[[package]]
name = "xshell"
version = "0.2.6"

View File

@ -13,7 +13,7 @@ edition = "2021"
# This is needed to make this package build on stable when the parent package uses unstable cargo features.
[dependencies]
which = "4.4"
which = "6.0"
walkdir = "2.3"
itertools = "0.11"
path_macro = "1.0"

View File

@ -1,5 +1,4 @@
use std::env;
use std::iter;
use std::{env, iter};
use anyhow::{Result, bail};

View File

@ -1,12 +1,9 @@
use std::env;
use std::ffi::{OsStr, OsString};
use std::io::Write;
use std::net;
use std::ops::Not;
use std::ops::Range;
use std::ops::{Not, Range};
use std::path::PathBuf;
use std::process;
use std::time::Duration;
use std::{env, net, process};
use anyhow::{Context, Result, anyhow, bail};
use path_macro::path;

View File

@ -1 +1 @@
6ce376774c0bc46ac8be247bca93ff5a1287a8fc
76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146

View File

@ -1,5 +1,10 @@
# This matches rustc
style_edition = "2024"
use_small_heuristics = "Max"
group_imports = "StdExternalCrate"
imports_granularity = "Module"
# Miri-specific settings
force_multiline_blocks = true
match_arm_blocks = false
match_arm_leading_pipes = "Preserve"
force_multiline_blocks = true

View File

@ -7,14 +7,13 @@ use std::cell::RefCell;
use std::cmp::max;
use rand::Rng;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_span::Span;
use rustc_target::abi::{Align, Size};
use crate::{concurrency::VClock, *};
use self::reuse_pool::ReusePool;
use crate::concurrency::VClock;
use crate::*;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum ProvenanceMode {

View File

@ -1,10 +1,10 @@
//! Manages a pool of addresses that can be reused.
use rand::Rng;
use rustc_target::abi::{Align, Size};
use crate::{MemoryKind, MiriConfig, ThreadId, concurrency::VClock};
use crate::concurrency::VClock;
use crate::{MemoryKind, MiriConfig, ThreadId};
const MAX_POOL_SIZE: usize = 64;

View File

@ -1,7 +1,6 @@
use std::alloc;
use std::alloc::Layout;
use std::borrow::Cow;
use std::slice;
use std::{alloc, slice};
use rustc_middle::mir::interpret::AllocBytes;
use rustc_target::abi::{Align, Size};

View File

@ -28,31 +28,27 @@ use std::num::NonZero;
use std::path::PathBuf;
use std::str::FromStr;
use tracing::debug;
use miri::{BacktraceStyle, BorrowTrackerMethod, ProvenanceMode, RetagFields, ValidationMode};
use rustc_data_structures::sync::Lrc;
use rustc_driver::Compilation;
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_hir::{self as hir, Node};
use rustc_hir_analysis::check::check_function_signature;
use rustc_interface::interface::Config;
use rustc_middle::{
middle::{
codegen_fn_attrs::CodegenFnAttrFlags,
exported_symbols::{ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel},
},
query::LocalCrate,
traits::{ObligationCause, ObligationCauseCode},
ty::{self, Ty, TyCtxt},
util::Providers,
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::middle::exported_symbols::{
ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
};
use rustc_middle::query::LocalCrate;
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::util::Providers;
use rustc_session::config::{CrateType, EntryFnType, ErrorOutputType, OptLevel};
use rustc_session::search_paths::PathKind;
use rustc_session::{CtfeBacktrace, EarlyDiagCtxt};
use rustc_span::def_id::DefId;
use rustc_target::spec::abi::Abi;
use miri::{BacktraceStyle, BorrowTrackerMethod, ProvenanceMode, RetagFields, ValidationMode};
use tracing::debug;
struct MiriCompilerCalls {
miri_config: miri::MiriConfig,

View File

@ -2,11 +2,10 @@ use std::cell::RefCell;
use std::fmt;
use std::num::NonZero;
use smallvec::SmallVec;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_middle::mir::RetagKind;
use rustc_target::abi::Size;
use smallvec::SmallVec;
use crate::*;
pub mod stacked_borrows;

View File

@ -1,9 +1,9 @@
use smallvec::SmallVec;
use std::fmt;
use rustc_data_structures::fx::FxHashSet;
use rustc_span::{Span, SpanData};
use rustc_target::abi::Size;
use smallvec::SmallVec;
use crate::borrow_tracker::{GlobalStateInner, ProtectorKind};
use crate::*;

View File

@ -6,25 +6,24 @@ mod item;
mod stack;
use std::cell::RefCell;
use std::cmp;
use std::fmt::Write;
use std::mem;
use std::{cmp, mem};
use rustc_data_structures::fx::FxHashSet;
use rustc_middle::mir::{Mutability, RetagKind};
use rustc_middle::ty::{self, Ty, layout::HasParamEnv};
use rustc_middle::ty::layout::HasParamEnv;
use rustc_middle::ty::{self, Ty};
use rustc_target::abi::{Abi, Size};
use crate::borrow_tracker::{
GlobalStateInner, ProtectorKind,
stacked_borrows::diagnostics::{AllocHistory, DiagnosticCx, DiagnosticCxBuilder},
};
use crate::concurrency::data_race::{NaReadType, NaWriteType};
use crate::*;
use self::diagnostics::{RetagCause, RetagInfo};
pub use self::item::{Item, Permission};
pub use self::stack::Stack;
use crate::borrow_tracker::stacked_borrows::diagnostics::{
AllocHistory, DiagnosticCx, DiagnosticCxBuilder,
};
use crate::borrow_tracker::{GlobalStateInner, ProtectorKind};
use crate::concurrency::data_race::{NaReadType, NaWriteType};
use crate::*;
pub type AllocState = Stacks;
@ -171,7 +170,7 @@ impl NewPermission {
/// F2b: No `SharedReadWrite` or `Unique` will ever be added on top of our `SharedReadOnly`.
/// F3: If an access happens with an `&` outside `UnsafeCell`,
/// it requires the `SharedReadOnly` to still be in the stack.
///
/// Core relation on `Permission` to define which accesses are allowed
impl Permission {
/// This defines for a given permission, whether it permits the given kind of access.

View File

@ -5,10 +5,8 @@ use rustc_data_structures::fx::FxHashSet;
use tracing::trace;
use crate::ProvenanceExtra;
use crate::borrow_tracker::{
AccessKind, BorTag,
stacked_borrows::{Item, Permission},
};
use crate::borrow_tracker::stacked_borrows::{Item, Permission};
use crate::borrow_tracker::{AccessKind, BorTag};
/// Exactly what cache size we should use is a difficult trade-off. There will always be some
/// workload which has a `BorTag` working set which exceeds the size of the cache, and ends up

View File

@ -5,11 +5,9 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_span::{Span, SpanData};
use crate::borrow_tracker::ProtectorKind;
use crate::borrow_tracker::tree_borrows::{
perms::{PermTransition, Permission},
tree::LocationState,
unimap::UniIndex,
};
use crate::borrow_tracker::tree_borrows::perms::{PermTransition, Permission};
use crate::borrow_tracker::tree_borrows::tree::LocationState;
use crate::borrow_tracker::tree_borrows::unimap::UniIndex;
use crate::*;
/// Cause of an access: either a real access or one

View File

@ -1,15 +1,12 @@
use rustc_middle::{
mir::{Mutability, RetagKind},
ty::{self, Ty, layout::HasParamEnv},
};
use rustc_middle::mir::{Mutability, RetagKind};
use rustc_middle::ty::layout::HasParamEnv;
use rustc_middle::ty::{self, Ty};
use rustc_span::def_id::DefId;
use rustc_target::abi::{Abi, Size};
use crate::borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind};
use crate::concurrency::data_race::NaReadType;
use crate::*;
use crate::{
borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind},
concurrency::data_race::NaReadType,
};
pub mod diagnostics;
mod perms;

View File

@ -12,18 +12,17 @@
use std::{fmt, mem};
use smallvec::SmallVec;
use rustc_data_structures::fx::FxHashSet;
use rustc_span::Span;
use rustc_target::abi::Size;
use smallvec::SmallVec;
use crate::borrow_tracker::tree_borrows::{
Permission,
diagnostics::{self, NodeDebugInfo, TbError, TransitionError},
perms::PermTransition,
unimap::{UniEntry, UniIndex, UniKeyMap, UniValMap},
use crate::borrow_tracker::tree_borrows::Permission;
use crate::borrow_tracker::tree_borrows::diagnostics::{
self, NodeDebugInfo, TbError, TransitionError,
};
use crate::borrow_tracker::tree_borrows::perms::PermTransition;
use crate::borrow_tracker::tree_borrows::unimap::{UniEntry, UniIndex, UniKeyMap, UniValMap};
use crate::borrow_tracker::{GlobalState, ProtectorKind};
use crate::*;

View File

@ -1,9 +1,10 @@
//! Tests for the tree
#![cfg(test)]
use std::fmt;
use super::*;
use crate::borrow_tracker::tree_borrows::exhaustive::{Exhaustive, precondition};
use std::fmt;
impl Exhaustive for LocationState {
fn exhaustive() -> Box<dyn Iterator<Item = Self>> {

View File

@ -12,7 +12,8 @@
#![allow(dead_code)]
use std::{hash::Hash, mem};
use std::hash::Hash;
use std::mem;
use rustc_data_structures::fx::FxHashMap;

View File

@ -40,28 +40,23 @@
//! code some atomic operations may increment the timestamp when not necessary but this has no effect
//! on the data-race detection code.
use std::{
cell::{Cell, Ref, RefCell, RefMut},
fmt::Debug,
mem,
};
use std::cell::{Cell, Ref, RefCell, RefMut};
use std::fmt::Debug;
use std::mem;
use rustc_ast::Mutability;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_index::{Idx, IndexVec};
use rustc_middle::{mir, ty::Ty};
use rustc_middle::mir;
use rustc_middle::ty::Ty;
use rustc_span::Span;
use rustc_target::abi::{Align, HasDataLayout, Size};
use super::vector_clock::{VClock, VTimestamp, VectorIdx};
use super::weak_memory::EvalContextExt as _;
use crate::diagnostics::RacingOp;
use crate::*;
use super::{
vector_clock::{VClock, VTimestamp, VectorIdx},
weak_memory::EvalContextExt as _,
};
pub type AllocState = VClockAlloc;
/// Valid atomic read-write orderings, alias of atomic::Ordering (not non-exhaustive).

View File

@ -2,10 +2,10 @@
//! ranges and data are discrete and non-splittable -- they represent distinct "objects". An
//! allocation in the map will always have the same range until explicitly removed
use rustc_target::abi::Size;
use std::ops::{Index, IndexMut, Range};
use rustc_const_eval::interpret::AllocRange;
use rustc_target::abi::Size;
#[derive(Clone, Debug)]
struct Elem<T> {

View File

@ -1,5 +1,6 @@
use std::any::Any;
use std::collections::{VecDeque, hash_map::Entry};
use std::collections::VecDeque;
use std::collections::hash_map::Entry;
use std::ops::Not;
use std::time::Duration;
@ -748,7 +749,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
}
),
);
return Ok(());
Ok(())
}
/// Wake up some thread (if there is any) sleeping on the conditional

View File

@ -7,7 +7,6 @@ use std::task::Poll;
use std::time::{Duration, SystemTime};
use either::Either;
use rustc_const_eval::CTRL_C_RECEIVED;
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::def_id::DefId;
@ -849,7 +848,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> {
// https://github.com/rust-lang/miri/issues/1763). In this case,
// just do nothing, which effectively just returns to the
// scheduler.
return Ok(());
Ok(())
}
#[inline]

View File

@ -1,11 +1,10 @@
use std::cmp::Ordering;
use std::fmt::Debug;
use std::ops::{Index, Shr};
use rustc_index::Idx;
use rustc_span::{DUMMY_SP, Span, SpanData};
use smallvec::SmallVec;
use std::{
cmp::Ordering,
fmt::Debug,
ops::{Index, Shr},
};
use super::data_race::NaReadType;
@ -430,10 +429,12 @@ impl Index<VectorIdx> for VClock {
/// test suite
#[cfg(test)]
mod tests {
use std::cmp::Ordering;
use rustc_span::DUMMY_SP;
use super::{VClock, VTimestamp, VectorIdx};
use crate::concurrency::data_race::NaReadType;
use rustc_span::DUMMY_SP;
use std::cmp::Ordering;
#[test]
fn test_equal() {

View File

@ -76,21 +76,16 @@
// (https://github.com/ChrisLidbury/tsan11/blob/ecbd6b81e9b9454e01cba78eb9d88684168132c7/lib/tsan/rtl/tsan_relaxed.cc#L295)
// and here.
use std::{
cell::{Ref, RefCell},
collections::VecDeque,
};
use std::cell::{Ref, RefCell};
use std::collections::VecDeque;
use rustc_data_structures::fx::FxHashMap;
use super::data_race::{GlobalState as DataRaceState, ThreadClockSet};
use super::range_object_map::{AccessType, RangeObjectMap};
use super::vector_clock::{VClock, VTimestamp, VectorIdx};
use crate::*;
use super::{
data_race::{GlobalState as DataRaceState, ThreadClockSet},
range_object_map::{AccessType, RangeObjectMap},
vector_clock::{VClock, VTimestamp, VectorIdx},
};
pub type AllocState = StoreBufferAlloc;
// Each store buffer must be bounded otherwise it will grow indefinitely.

View File

@ -1,25 +1,21 @@
//! Main evaluator loop and setting up the initial stack frame.
use std::ffi::{OsStr, OsString};
use std::iter;
use std::panic::{self, AssertUnwindSafe};
use std::path::PathBuf;
use std::task::Poll;
use std::thread;
use std::{iter, thread};
use crate::concurrency::thread::TlsAllocAction;
use crate::diagnostics::report_leaks;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir::def::Namespace;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::{
self, Ty, TyCtxt,
layout::{LayoutCx, LayoutOf},
};
use rustc_middle::ty::layout::{LayoutCx, LayoutOf};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_session::config::EntryFnType;
use rustc_target::spec::abi::Abi;
use rustc_session::config::EntryFnType;
use crate::concurrency::thread::TlsAllocAction;
use crate::diagnostics::report_leaks;
use crate::shims::tls;
use crate::*;

View File

@ -1,29 +1,22 @@
use std::cmp;
use std::collections::BTreeSet;
use std::iter;
use std::num::NonZero;
use std::sync::Mutex;
use std::time::Duration;
use std::{cmp, iter};
use rand::RngCore;
use rustc_apfloat::Float;
use rustc_apfloat::ieee::{Double, Half, Quad, Single};
use rustc_hir::{
Safety,
def::{DefKind, Namespace},
def_id::{CRATE_DEF_INDEX, CrateNum, DefId, LOCAL_CRATE},
};
use rustc_hir::Safety;
use rustc_hir::def::{DefKind, Namespace};
use rustc_hir::def_id::{CRATE_DEF_INDEX, CrateNum, DefId, LOCAL_CRATE};
use rustc_index::IndexVec;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::middle::exported_symbols::ExportedSymbol;
use rustc_middle::mir;
use rustc_middle::ty::layout::{FnAbiOf, MaybeResult};
use rustc_middle::ty::{
self, FloatTy, IntTy, Ty, TyCtxt, UintTy,
layout::{LayoutOf, TyAndLayout},
};
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, MaybeResult, TyAndLayout};
use rustc_middle::ty::{self, FloatTy, IntTy, Ty, TyCtxt, UintTy};
use rustc_session::config::CrateType;
use rustc_span::{Span, Symbol};
use rustc_target::abi::{Align, FieldIdx, FieldsShape, Size, Variants};

View File

@ -1,7 +1,8 @@
use rustc_middle::{mir, mir::BinOp, ty};
use rustc_middle::mir::BinOp;
use rustc_middle::{mir, ty};
use crate::*;
use self::helpers::check_arg_count;
use crate::*;
pub enum AtomicOp {
/// The `bool` indicates whether the result of the operation should be negated (`UnOp::Not`,

View File

@ -5,17 +5,15 @@ mod simd;
use rand::Rng;
use rustc_apfloat::{Float, Round};
use rustc_middle::{
mir,
ty::{self, FloatTy},
};
use rustc_middle::mir;
use rustc_middle::ty::{self, FloatTy};
use rustc_span::{Symbol, sym};
use rustc_target::abi::Size;
use crate::*;
use self::atomic::EvalContextExt as _;
use self::helpers::{ToHost, ToSoft, check_arg_count};
use self::simd::EvalContextExt as _;
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {

View File

@ -1,8 +1,8 @@
use either::Either;
use rustc_apfloat::{Float, Round};
use rustc_middle::ty::FloatTy;
use rustc_middle::ty::layout::{HasParamEnv, LayoutOf};
use rustc_middle::{mir, ty, ty::FloatTy};
use rustc_middle::{mir, ty};
use rustc_span::{Symbol, sym};
use rustc_target::abi::{Endian, HasDataLayout};

View File

@ -32,10 +32,7 @@
clippy::derived_hash_with_manual_eq,
clippy::too_many_arguments,
clippy::type_complexity,
clippy::single_element_loop,
clippy::needless_return,
clippy::bool_to_int_with_if,
clippy::box_default,
clippy::needless_question_mark,
clippy::needless_lifetimes,
clippy::too_long_first_doc_paragraph,
@ -95,15 +92,14 @@ mod range_map;
mod shims;
// Establish a "crate-wide prelude": we often import `crate::*`.
use rustc_middle::{bug, span_bug};
use tracing::{info, trace};
// Make all those symbols available in the same place as our own.
#[doc(no_inline)]
pub use rustc_const_eval::interpret::*;
// Resolve ambiguity.
#[doc(no_inline)]
pub use rustc_const_eval::interpret::{self, AllocMap, Provenance as _};
use rustc_middle::{bug, span_bug};
use tracing::{info, trace};
// Type aliases that set the provenance parameter.
pub type Pointer = interpret::Pointer<Option<machine::Provenance>>;
@ -114,15 +110,6 @@ pub type OpTy<'tcx> = interpret::OpTy<'tcx, machine::Provenance>;
pub type PlaceTy<'tcx> = interpret::PlaceTy<'tcx, machine::Provenance>;
pub type MPlaceTy<'tcx> = interpret::MPlaceTy<'tcx, machine::Provenance>;
pub use crate::intrinsics::EvalContextExt as _;
pub use crate::shims::EmulateItemResult;
pub use crate::shims::env::{EnvVars, EvalContextExt as _};
pub use crate::shims::foreign_items::{DynSym, EvalContextExt as _};
pub use crate::shims::os_str::EvalContextExt as _;
pub use crate::shims::panic::{CatchUnwindData, EvalContextExt as _};
pub use crate::shims::time::EvalContextExt as _;
pub use crate::shims::tls::TlsData;
pub use crate::alloc_addresses::{EvalContextExt as _, ProvenanceMode};
pub use crate::alloc_bytes::MiriAllocBytes;
pub use crate::borrow_tracker::stacked_borrows::{
@ -131,15 +118,17 @@ pub use crate::borrow_tracker::stacked_borrows::{
pub use crate::borrow_tracker::tree_borrows::{EvalContextExt as _, Tree};
pub use crate::borrow_tracker::{BorTag, BorrowTrackerMethod, EvalContextExt as _, RetagFields};
pub use crate::clock::{Clock, Instant};
pub use crate::concurrency::{
cpu_affinity::MAX_CPUS,
data_race::{AtomicFenceOrd, AtomicReadOrd, AtomicRwOrd, AtomicWriteOrd, EvalContextExt as _},
init_once::{EvalContextExt as _, InitOnceId},
sync::{CondvarId, EvalContextExt as _, MutexId, RwLockId, SynchronizationObjects},
thread::{
BlockReason, EvalContextExt as _, StackEmptyCallback, ThreadId, ThreadManager,
TimeoutAnchor, TimeoutClock, UnblockCallback,
},
pub use crate::concurrency::cpu_affinity::MAX_CPUS;
pub use crate::concurrency::data_race::{
AtomicFenceOrd, AtomicReadOrd, AtomicRwOrd, AtomicWriteOrd, EvalContextExt as _,
};
pub use crate::concurrency::init_once::{EvalContextExt as _, InitOnceId};
pub use crate::concurrency::sync::{
CondvarId, EvalContextExt as _, MutexId, RwLockId, SynchronizationObjects,
};
pub use crate::concurrency::thread::{
BlockReason, EvalContextExt as _, StackEmptyCallback, ThreadId, ThreadManager, TimeoutAnchor,
TimeoutClock, UnblockCallback,
};
pub use crate::diagnostics::{
EvalContextExt as _, NonHaltingDiagnostic, TerminationInfo, report_error,
@ -149,6 +138,7 @@ pub use crate::eval::{
create_ecx, eval_entry,
};
pub use crate::helpers::{AccessKind, EvalContextExt as _};
pub use crate::intrinsics::EvalContextExt as _;
pub use crate::machine::{
AllocExtra, FrameExtra, MemoryKind, MiriInterpCx, MiriInterpCxExt, MiriMachine, MiriMemoryKind,
PrimitiveLayouts, Provenance, ProvenanceExtra,
@ -157,6 +147,13 @@ pub use crate::mono_hash_map::MonoHashMap;
pub use crate::operator::EvalContextExt as _;
pub use crate::provenance_gc::{EvalContextExt as _, LiveAllocs, VisitProvenance, VisitWith};
pub use crate::range_map::RangeMap;
pub use crate::shims::EmulateItemResult;
pub use crate::shims::env::{EnvVars, EvalContextExt as _};
pub use crate::shims::foreign_items::{DynSym, EvalContextExt as _};
pub use crate::shims::os_str::EvalContextExt as _;
pub use crate::shims::panic::{CatchUnwindData, EvalContextExt as _};
pub use crate::shims::time::EvalContextExt as _;
pub use crate::shims::tls::TlsData;
/// Insert rustc arguments at the beginning of the argument list that Miri wants to be
/// set per default, for maximal validation power.

View File

@ -4,40 +4,29 @@
use std::borrow::Cow;
use std::cell::RefCell;
use std::collections::hash_map::Entry;
use std::fmt;
use std::path::Path;
use std::process;
use std::{fmt, process};
use rand::Rng;
use rand::SeedableRng;
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use rustc_attr::InlineAttr;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
#[allow(unused)]
use rustc_data_structures::static_assert_size;
use rustc_middle::{
mir,
query::TyCtxtAt,
ty::{
self, Instance, Ty, TyCtxt,
layout::{HasTyCtxt, LayoutCx, LayoutError, LayoutOf, TyAndLayout},
},
};
use rustc_middle::mir;
use rustc_middle::query::TyCtxtAt;
use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError, LayoutOf, TyAndLayout};
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
use rustc_session::config::InliningThreshold;
use rustc_span::def_id::{CrateNum, DefId};
use rustc_span::{Span, SpanData, Symbol};
use rustc_target::abi::{Align, Size};
use rustc_target::spec::abi::Abi;
use crate::{
concurrency::{
cpu_affinity::{self, CpuAffinityMask},
data_race::{self, NaReadType, NaWriteType},
weak_memory,
},
*,
};
use crate::concurrency::cpu_affinity::{self, CpuAffinityMask};
use crate::concurrency::data_race::{self, NaReadType, NaWriteType};
use crate::concurrency::weak_memory;
use crate::*;
/// First real-time signal.
/// `signal(7)` says this must be between 32 and 64 and specifies 34 or 35

View File

@ -1,6 +1,7 @@
use std::iter;
use rand::{Rng, seq::IteratorRandom};
use rand::Rng;
use rand::seq::IteratorRandom;
use rustc_apfloat::{Float, FloatConvert};
use rustc_middle::mir;
use rustc_target::abi::Size;

View File

@ -1,5 +1,4 @@
use either::Either;
use rustc_data_structures::fx::FxHashSet;
use crate::*;

View File

@ -71,7 +71,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
// and not execute any Miri shim. Somewhat unintuitively doing so is done
// by returning `NotSupported`, which triggers the `lookup_exported_symbol`
// fallback case in `emulate_foreign_item`.
return Ok(EmulateItemResult::NotSupported);
Ok(EmulateItemResult::NotSupported)
}
AllocatorKind::Default => {
default(this)?;

View File

@ -1,9 +1,11 @@
use crate::*;
use rustc_ast::ast::Mutability;
use rustc_middle::ty::layout::LayoutOf as _;
use rustc_middle::ty::{self, Instance, Ty};
use rustc_span::{BytePos, Loc, Symbol, hygiene};
use rustc_target::{abi::Size, spec::abi::Abi};
use rustc_target::abi::Size;
use rustc_target::spec::abi::Abi;
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {

View File

@ -2,8 +2,9 @@ use std::ffi::{OsStr, OsString};
use rustc_data_structures::fx::FxHashMap;
use self::shims::unix::UnixEnvVars;
use self::shims::windows::WindowsEnvVars;
use crate::*;
use self::shims::{unix::UnixEnvVars, windows::WindowsEnvVars};
#[derive(Default)]
pub enum EnvVars<'tcx> {
@ -103,7 +104,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn get_env_var(&mut self, name: &OsStr) -> InterpResult<'tcx, Option<OsString>> {
let this = self.eval_context_ref();
match &this.machine.env_vars {
EnvVars::Uninit => return Ok(None),
EnvVars::Uninit => Ok(None),
EnvVars::Unix(vars) => vars.get(this, name),
EnvVars::Windows(vars) => vars.get(name),
}

View File

@ -1,21 +1,22 @@
use std::{collections::hash_map::Entry, io::Write, iter, path::Path};
use std::collections::hash_map::Entry;
use std::io::Write;
use std::iter;
use std::path::Path;
use rustc_apfloat::Float;
use rustc_ast::expand::allocator::alloc_error_handler_name;
use rustc_hir::{def::DefKind, def_id::CrateNum};
use rustc_hir::def::DefKind;
use rustc_hir::def_id::CrateNum;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir;
use rustc_middle::ty;
use rustc_middle::{mir, ty};
use rustc_span::Symbol;
use rustc_target::{
abi::{Align, AlignFromBytesError, Size},
spec::abi::Abi,
};
use rustc_target::abi::{Align, AlignFromBytesError, Size};
use rustc_target::spec::abi::Abi;
use self::helpers::{ToHost, ToSoft};
use super::alloc::EvalContextExt as _;
use super::backtrace::EvalContextExt as _;
use crate::*;
use self::helpers::{ToHost, ToSoft};
/// Type of dynamic symbols (for `dlsym` et al)
#[derive(Debug, Copy, Clone)]

View File

@ -1,7 +1,8 @@
//! Implements calling functions from a native library.
use libffi::{high::call as ffi, low::CodePtr};
use std::ops::Deref;
use libffi::high::call as ffi;
use libffi::low::CodePtr;
use rustc_middle::ty::{self as ty, IntTy, UintTy};
use rustc_span::Symbol;
use rustc_target::abi::{Abi, HasDataLayout};

View File

@ -1,11 +1,10 @@
use std::borrow::Cow;
use std::ffi::{OsStr, OsString};
use std::path::{Path, PathBuf};
#[cfg(unix)]
use std::os::unix::ffi::{OsStrExt, OsStringExt};
#[cfg(windows)]
use std::os::windows::ffi::{OsStrExt, OsStringExt};
use std::path::{Path, PathBuf};
use rustc_middle::ty::Ty;
use rustc_middle::ty::layout::LayoutOf;

View File

@ -16,8 +16,8 @@ use rustc_middle::{mir, ty};
use rustc_target::spec::PanicStrategy;
use rustc_target::spec::abi::Abi;
use crate::*;
use self::helpers::check_arg_count;
use crate::*;
/// Holds all of the relevant data for when unwinding hits a `try` frame.
#[derive(Debug)]

View File

@ -36,8 +36,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let mut relative_clocks;
match this.tcx.sess.target.os.as_ref() {
"linux" | "freebsd" => {
// Linux and FreeBSD have two main kinds of clocks. REALTIME clocks return the actual time since the
"linux" | "freebsd" | "android" => {
// Linux, Android, and FreeBSD have two main kinds of clocks. REALTIME clocks return the actual time since the
// Unix epoch, including effects which may cause time to move backwards such as NTP.
// Linux further distinguishes regular and "coarse" clocks, but the "coarse" version
// is just specified to be "faster and less precise", so we implement both the same way.

View File

@ -1,7 +1,6 @@
use std::env;
use std::ffi::{OsStr, OsString};
use std::io::ErrorKind;
use std::mem;
use std::{env, mem};
use rustc_data_structures::fx::FxHashMap;
use rustc_middle::ty::Ty;

View File

@ -5,8 +5,7 @@ use std::any::Any;
use std::collections::BTreeMap;
use std::io::{self, ErrorKind, IsTerminal, Read, SeekFrom, Write};
use std::ops::Deref;
use std::rc::Rc;
use std::rc::Weak;
use std::rc::{Rc, Weak};
use rustc_target::abi::Size;
@ -676,12 +675,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.write_bytes_ptr(buf, bytes[..read_bytes].iter().copied())?;
// The actual read size is always less than what got originally requested so this cannot fail.
this.write_int(u64::try_from(read_bytes).unwrap(), dest)?;
return Ok(());
Ok(())
}
Err(e) => {
this.set_last_error_from_io_error(e)?;
this.write_int(-1, dest)?;
return Ok(());
Ok(())
}
}
}

View File

@ -6,16 +6,15 @@ use rustc_span::Symbol;
use rustc_target::abi::Size;
use rustc_target::spec::abi::Abi;
use crate::concurrency::cpu_affinity::CpuAffinityMask;
use crate::shims::alloc::EvalContextExt as _;
use crate::shims::unix::*;
use crate::*;
use self::shims::unix::android::foreign_items as android;
use self::shims::unix::freebsd::foreign_items as freebsd;
use self::shims::unix::linux::foreign_items as linux;
use self::shims::unix::macos::foreign_items as macos;
use self::shims::unix::solarish::foreign_items as solarish;
use crate::concurrency::cpu_affinity::CpuAffinityMask;
use crate::shims::alloc::EvalContextExt as _;
use crate::shims::unix::*;
use crate::*;
pub fn is_dyn_sym(name: &str, target_os: &str) -> bool {
match name {
@ -792,6 +791,20 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.gen_random(ptr, len)?;
this.write_scalar(Scalar::from_target_usize(len, this), dest)?;
}
"arc4random_buf" => {
// This function is non-standard but exists with the same signature and
// same behavior (eg never fails) on FreeBSD and Solaris/Illumos.
if !matches!(&*this.tcx.sess.target.os, "freebsd" | "illumos" | "solaris") {
throw_unsup_format!(
"`arc4random_buf` is not supported on {}",
this.tcx.sess.target.os
);
}
let [ptr, len] = this.check_shim(abi, Abi::C { unwind: false}, link_name, args)?;
let ptr = this.read_pointer(ptr)?;
let len = this.read_target_usize(len)?;
this.gen_random(ptr, len)?;
}
"_Unwind_RaiseException" => {
// This is not formally part of POSIX, but it is very wide-spread on POSIX systems.
// It was originally specified as part of the Itanium C++ ABI:

View File

@ -11,13 +11,12 @@ use std::time::SystemTime;
use rustc_data_structures::fx::FxHashMap;
use rustc_target::abi::Size;
use self::fd::FlockOp;
use self::shims::time::system_time_to_duration;
use crate::shims::os_str::bytes_to_os_str;
use crate::shims::unix::fd::FileDescriptionRef;
use crate::shims::unix::*;
use crate::*;
use self::shims::time::system_time_to_duration;
use self::fd::FlockOp;
#[derive(Debug)]
struct FileHandle {
@ -186,12 +185,14 @@ impl FileDescription for FileHandle {
#[cfg(target_family = "windows")]
{
use std::os::windows::io::AsRawHandle;
use windows_sys::Win32::{
Foundation::{ERROR_IO_PENDING, ERROR_LOCK_VIOLATION, FALSE, HANDLE, TRUE},
Storage::FileSystem::{
LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, LockFileEx, UnlockFile,
},
use windows_sys::Win32::Foundation::{
ERROR_IO_PENDING, ERROR_LOCK_VIOLATION, FALSE, HANDLE, TRUE,
};
use windows_sys::Win32::Storage::FileSystem::{
LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, LockFileEx, UnlockFile,
};
let fh = self.file.as_raw_handle() as HANDLE;
use FlockOp::*;

View File

@ -401,19 +401,19 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
/// list about file descriptors in the interest list that have some
/// events available. Up to `maxevents` are returned by `epoll_wait()`.
/// The `maxevents` argument must be greater than zero.
///
/// The `timeout` argument specifies the number of milliseconds that
/// `epoll_wait()` will block. Time is measured against the
/// CLOCK_MONOTONIC clock. If the timeout is zero, the function will not block,
/// while if the timeout is -1, the function will block
/// until at least one event has been retrieved (or an error
/// occurred).
///
/// A call to `epoll_wait()` will block until either:
/// • a file descriptor delivers an event;
/// • the call is interrupted by a signal handler; or
/// • the timeout expires.
///
/// Note that the timeout interval will be rounded up to the system
/// clock granularity, and kernel scheduling delays mean that the
/// blocking interval may overrun by a small amount. Specifying a
@ -596,7 +596,7 @@ fn ready_list_next(
return Some(epoll_event_instance);
}
}
return None;
None
}
/// This helper function checks whether an epoll notification should be triggered for a specific
@ -623,9 +623,10 @@ fn check_and_update_one_event_interest<'tcx>(
let event_instance = EpollEventInstance::new(flags, epoll_event_interest.data);
// Triggers the notification by inserting it to the ready list.
ready_list.insert(epoll_key, event_instance);
return Ok(true);
Ok(true)
} else {
Ok(false)
}
return Ok(false);
}
/// Callback function after epoll_wait unblocks

View File

@ -3,10 +3,11 @@ use std::cell::{Cell, RefCell};
use std::io;
use std::io::{Error, ErrorKind};
use crate::concurrency::VClock;
use crate::shims::unix::fd::FileDescriptionRef;
use crate::shims::unix::linux::epoll::{EpollReadyEvents, EvalContextExt as _};
use crate::shims::unix::*;
use crate::{concurrency::VClock, *};
use crate::*;
/// Maximum value that the eventfd counter can hold.
const MAX_COUNTER: u64 = u64::MAX - 1;
@ -110,7 +111,7 @@ impl FileDescription for Event {
/// write either blocks until a read is performed on the
/// file descriptor, or fails with the error EAGAIN if the
/// file descriptor has been made nonblocking.
///
/// A write fails with the error EINVAL if the size of the
/// supplied buffer is less than 8 bytes, or if an attempt is
/// made to write the value 0xffffffffffffffff.

View File

@ -1,14 +1,13 @@
use rustc_span::Symbol;
use rustc_target::spec::abi::Abi;
use crate::machine::SIGRTMAX;
use crate::machine::SIGRTMIN;
use crate::shims::unix::*;
use crate::*;
use self::shims::unix::linux::epoll::EvalContextExt as _;
use self::shims::unix::linux::eventfd::EvalContextExt as _;
use self::shims::unix::linux::mem::EvalContextExt as _;
use self::shims::unix::linux::sync::futex;
use crate::machine::{SIGRTMAX, SIGRTMIN};
use crate::shims::unix::*;
use crate::*;
pub fn is_dyn_sym(name: &str) -> bool {
matches!(name, "statx")

View File

@ -1,9 +1,10 @@
//! This follows the pattern in src/shims/unix/mem.rs: We only support uses of mremap that would
//! correspond to valid uses of realloc.
use crate::*;
use rustc_target::abi::Size;
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn mremap(

View File

@ -80,7 +80,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
// Random data generation
"CCRandomGenerateBytes" => {
let [bytes, count] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
let [bytes, count] =
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
let bytes = this.read_pointer(bytes)?;
let count = this.read_target_usize(count)?;
let success = this.eval_libc_i32("kCCSuccess");

View File

@ -14,9 +14,10 @@
//! munmap shim which would partially unmap a region of address space previously mapped by mmap will
//! report UB.
use crate::*;
use rustc_target::abi::Size;
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn mmap(

View File

@ -14,14 +14,11 @@ mod linux;
mod macos;
mod solarish;
pub use self::env::UnixEnvVars;
pub use self::fd::{FdTable, FileDescription};
pub use self::fs::DirTable;
pub use self::linux::epoll::EpollInterestTable;
// All the Unix-specific extension traits
pub use self::env::EvalContextExt as _;
pub use self::fd::EvalContextExt as _;
pub use self::fs::EvalContextExt as _;
pub use self::env::{EvalContextExt as _, UnixEnvVars};
pub use self::fd::{EvalContextExt as _, FdTable, FileDescription};
pub use self::fs::{DirTable, EvalContextExt as _};
pub use self::linux::epoll::EpollInterestTable;
pub use self::mem::EvalContextExt as _;
pub use self::sync::EvalContextExt as _;
pub use self::thread::EvalContextExt as _;

View File

@ -1,6 +1,7 @@
use crate::*;
use rustc_target::spec::abi::Abi;
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn pthread_create(

View File

@ -9,10 +9,11 @@ use std::io::{Error, ErrorKind, Read};
use rustc_target::abi::Size;
use crate::concurrency::VClock;
use crate::shims::unix::fd::{FileDescriptionRef, WeakFileDescriptionRef};
use crate::shims::unix::linux::epoll::{EpollReadyEvents, EvalContextExt as _};
use crate::shims::unix::*;
use crate::{concurrency::VClock, *};
use crate::*;
/// The maximum capacity of the socketpair buffer in bytes.
/// This number is arbitrary as the value can always

View File

@ -4,8 +4,8 @@ use std::io::ErrorKind;
use rustc_data_structures::fx::FxHashMap;
use crate::*;
use self::helpers::windows_check_buffer_size;
use crate::*;
#[derive(Default)]
pub struct WindowsEnvVars {

View File

@ -1,17 +1,15 @@
use std::ffi::OsStr;
use std::io;
use std::iter;
use std::path::{self, Path, PathBuf};
use std::str;
use std::{io, iter, str};
use rustc_span::Symbol;
use rustc_target::abi::{Align, Size};
use rustc_target::spec::abi::Abi;
use self::shims::windows::handle::{Handle, PseudoHandle};
use crate::shims::os_str::bytes_to_os_str;
use crate::shims::windows::*;
use crate::*;
use self::shims::windows::handle::{Handle, PseudoHandle};
pub fn is_dyn_sym(name: &str) -> bool {
// std does dynamic detection for these symbols
@ -23,8 +21,8 @@ pub fn is_dyn_sym(name: &str) -> bool {
#[cfg(windows)]
fn win_absolute<'tcx>(path: &Path) -> InterpResult<'tcx, io::Result<PathBuf>> {
// We are on Windows so we can simply lte the host do this.
return Ok(path::absolute(path));
// We are on Windows so we can simply let the host do this.
Ok(path::absolute(path))
}
#[cfg(unix)]

View File

@ -1,6 +1,7 @@
use rustc_target::abi::HasDataLayout;
use std::mem::variant_count;
use rustc_target::abi::HasDataLayout;
use crate::*;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]

View File

@ -5,9 +5,8 @@ mod handle;
mod sync;
mod thread;
pub use self::env::WindowsEnvVars;
// All the Windows-specific extension traits
pub use self::env::EvalContextExt as _;
pub use self::env::{EvalContextExt as _, WindowsEnvVars};
pub use self::handle::EvalContextExt as _;
pub use self::sync::EvalContextExt as _;
pub use self::thread::EvalContextExt as _;

View File

@ -90,7 +90,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
}
),
);
return Ok(());
Ok(())
}
fn InitOnceComplete(

View File

@ -1,8 +1,8 @@
use rustc_middle::ty::layout::LayoutOf;
use rustc_target::spec::abi::Abi;
use crate::*;
use self::shims::windows::handle::{EvalContextExt as _, Handle, PseudoHandle};
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}

View File

@ -1,4 +1,4 @@
use rustc_apfloat::{ieee::Double, ieee::Single};
use rustc_apfloat::ieee::{Double, Single};
use rustc_middle::mir;
use rustc_middle::ty::Ty;
use rustc_middle::ty::layout::LayoutOf as _;

View File

@ -1,6 +1,6 @@
use rand::Rng as _;
use rustc_apfloat::{Float, ieee::Single};
use rustc_apfloat::Float;
use rustc_apfloat::ieee::Single;
use rustc_middle::ty::Ty;
use rustc_middle::ty::layout::LayoutOf as _;
use rustc_middle::{mir, ty};
@ -8,8 +8,8 @@ use rustc_span::Symbol;
use rustc_target::abi::Size;
use rustc_target::spec::abi::Abi;
use crate::*;
use self::helpers::bool_to_simd_element;
use crate::*;
mod aesni;
mod avx;

View File

@ -1,9 +1,10 @@
use byteorder::{BigEndian, ByteOrder};
use std::env;
#[cfg(unix)]
use std::io::{self, BufRead};
use std::path::PathBuf;
use byteorder::{BigEndian, ByteOrder};
fn main() {
// Check env var set by `build.rs`.
assert_eq!(env!("MIRITESTVAR"), "testval");

View File

@ -1,5 +1,4 @@
use std::env;
use std::path::PathBuf;
use byteorder::{ByteOrder, LittleEndian};

View File

@ -52,9 +52,12 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"
[[package]]
name = "cc"
version = "1.1.7"
version = "1.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc"
checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0"
dependencies = [
"shlex",
]
[[package]]
name = "cfg-if"
@ -261,6 +264,12 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "signal-hook-registry"
version = "1.4.2"

View File

@ -1,25 +0,0 @@
{
"arch": "avr",
"cpu": "atmega328p",
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
"env": "",
"executables": true,
"linker": "avr-gcc",
"linker-flavor": "gcc",
"linker-is-gnu": true,
"llvm-target": "avr-unknown-unknown",
"os": "unknown",
"position-independent-executables": false,
"exe-suffix": ".elf",
"eh-frame-header": false,
"pre-link-args": {
"gcc": ["-mmcu=atmega328p"]
},
"late-link-args": {
"gcc": ["-lgcc"]
},
"target-c-int-width": "16",
"target-endian": "little",
"target-pointer-width": "16",
"vendor": "unknown"
}

View File

@ -2,8 +2,7 @@
// Joining the same thread from multiple threads is undefined behavior.
use std::thread;
use std::{mem, ptr};
use std::{mem, ptr, thread};
extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void {
// Yield the thread several times so that other threads can join it.

View File

@ -3,10 +3,10 @@
//@compile-flags: -Zmiri-disable-isolation -Zmiri-num-cpus=4
fn main() {
use libc::{cpu_set_t, sched_setaffinity};
use std::mem::size_of;
use libc::{cpu_set_t, sched_setaffinity};
// If pid is zero, then the calling thread is used.
const PID: i32 = 0;

View File

@ -1,8 +1,7 @@
//@compile-flags: -Zmiri-disable-isolation -Zmiri-preemption-rate=0
//@ignore-target: windows # No libc env support on Windows
use std::env;
use std::thread;
use std::{env, thread};
fn main() {
let t = thread::spawn(|| unsafe {

View File

@ -1,10 +1,8 @@
//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
use std::{
ops::{Coroutine, CoroutineState},
pin::Pin,
};
use std::ops::{Coroutine, CoroutineState};
use std::pin::Pin;
fn firstn() -> impl Coroutine<Yield = u64, Return = ()> {
#[coroutine]

View File

@ -3,8 +3,7 @@
// Avoid accidental synchronization via address reuse inside `thread::spawn`.
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread::spawn;
#[derive(Copy, Clone)]

View File

@ -3,8 +3,7 @@
// Avoid accidental synchronization via address reuse inside `thread::spawn`.
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread::spawn;
#[derive(Copy, Clone)]

View File

@ -3,8 +3,7 @@
// Avoid accidental synchronization via address reuse inside `thread::spawn`.
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread::spawn;
#[derive(Copy, Clone)]

View File

@ -0,0 +1,11 @@
//@error-in-other-file: the program aborted execution
//@normalize-stderr-test: "unsafe \{ libc::abort\(\) \}|crate::intrinsics::abort\(\);" -> "ABORT();"
//@normalize-stderr-test: "\| +\^+" -> "| ^"
//@normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> ""
//@normalize-stderr-test: "\n +at [^\n]+" -> ""
#![feature(abort_unwind)]
fn main() {
std::panic::abort_unwind(|| panic!("PANIC!!!"));
}

View File

@ -0,0 +1,33 @@
thread 'main' panicked at tests/fail/panic/abort_unwind.rs:LL:CC:
PANIC!!!
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
panic in a function that cannot unwind
stack backtrace:
thread caused non-unwinding panic. aborting.
error: abnormal termination: the program aborted execution
--> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
|
LL | ABORT();
| ^ the program aborted execution
|
= note: BACKTRACE:
= note: inside `std::sys::pal::PLATFORM::abort_internal` at RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
= note: inside `std::panicking::rust_panic_with_hook` at RUSTLIB/std/src/panicking.rs:LL:CC
= note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
= note: inside `std::sys::backtrace::__rust_end_short_backtrace::<{closure@std::panicking::begin_panic_handler::{closure#0}}, !>` at RUSTLIB/std/src/sys/backtrace.rs:LL:CC
= note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC
= note: inside `core::panicking::panic_nounwind` at RUSTLIB/core/src/panicking.rs:LL:CC
= note: inside `core::panicking::panic_cannot_unwind` at RUSTLIB/core/src/panicking.rs:LL:CC
= note: inside `std::panic::abort_unwind::<{closure@tests/fail/panic/abort_unwind.rs:LL:CC}, ()>` at RUSTLIB/core/src/panic.rs:LL:CC
note: inside `main`
--> tests/fail/panic/abort_unwind.rs:LL:CC
|
LL | std::panic::abort_unwind(|| panic!("PANIC!!!"));
| ^
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to 1 previous error

View File

@ -8,8 +8,7 @@
#![feature(ptr_internals)]
use core::ptr::Unique;
use core::ptr::addr_of_mut;
use core::ptr::{Unique, addr_of_mut};
fn main() {
let mut data = 0u8;

View File

@ -0,0 +1,32 @@
//! Ensure that a box with a custom allocator detects when the pointer is dangling.
#![feature(allocator_api)]
// This should not need the aliasing model.
//@compile-flags: -Zmiri-disable-stacked-borrows
use std::alloc::Layout;
use std::ptr::NonNull;
#[allow(unused)]
struct MyAlloc(usize, usize); // make sure `Box<T, MyAlloc>` is an `Aggregate`
unsafe impl std::alloc::Allocator for MyAlloc {
fn allocate(&self, _layout: Layout) -> Result<NonNull<[u8]>, std::alloc::AllocError> {
unimplemented!()
}
unsafe fn deallocate(&self, _ptr: NonNull<u8>, _layout: Layout) {
unimplemented!()
}
}
#[repr(C)]
struct MyBox<T> {
ptr: NonNull<T>,
alloc: MyAlloc,
}
fn main() {
let b = MyBox { ptr: NonNull::<i32>::dangling(), alloc: MyAlloc(0, 0) };
let _b: Box<i32, MyAlloc> = unsafe {
std::mem::transmute(b) //~ERROR: dangling box
};
}

View File

@ -0,0 +1,15 @@
error: Undefined Behavior: constructing invalid value: encountered a dangling box (0x4[noalloc] has no provenance)
--> tests/fail/validity/box-custom-alloc-dangling-ptr.rs:LL:CC
|
LL | std::mem::transmute(b)
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x4[noalloc] has no provenance)
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `main` at tests/fail/validity/box-custom-alloc-dangling-ptr.rs:LL:CC
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to 1 previous error

View File

@ -0,0 +1,37 @@
//! Ensure that a box with a custom allocator detects when the allocator itself is invalid.
#![feature(allocator_api)]
// This should not need the aliasing model.
//@compile-flags: -Zmiri-disable-stacked-borrows
use std::alloc::Layout;
use std::mem::MaybeUninit;
use std::ptr::NonNull;
// make sure `Box<T, MyAlloc>` is an `Aggregate`
#[allow(unused)]
struct MyAlloc {
my_alloc_field1: usize,
my_alloc_field2: usize,
}
unsafe impl std::alloc::Allocator for MyAlloc {
fn allocate(&self, _layout: Layout) -> Result<NonNull<[u8]>, std::alloc::AllocError> {
unimplemented!()
}
unsafe fn deallocate(&self, _ptr: NonNull<u8>, _layout: Layout) {
unimplemented!()
}
}
#[repr(C)]
struct MyBox<T> {
ptr: NonNull<T>,
alloc: MaybeUninit<MyAlloc>,
}
fn main() {
let b = MyBox { ptr: NonNull::from(&42), alloc: MaybeUninit::uninit() };
let _b: Box<i32, MyAlloc> = unsafe {
std::mem::transmute(b) //~ERROR: uninitialized memory
};
}

View File

@ -0,0 +1,15 @@
error: Undefined Behavior: constructing invalid value at .1.my_alloc_field1: encountered uninitialized memory, but expected an integer
--> tests/fail/validity/box-custom-alloc-invalid-alloc.rs:LL:CC
|
LL | std::mem::transmute(b)
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .1.my_alloc_field1: encountered uninitialized memory, but expected an integer
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `main` at tests/fail/validity/box-custom-alloc-invalid-alloc.rs:LL:CC
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to 1 previous error

View File

@ -5,7 +5,9 @@ trait Trait {
impl<T: Copy> Trait for T {
type Assoc = T;
fn foo(&self) -> T { *self }
fn foo(&self) -> T {
*self
}
}
fn main() {

View File

@ -6,8 +6,7 @@
use std::mem::MaybeUninit;
use std::ptr::{self, addr_of};
use std::sync::atomic::AtomicI32;
use std::sync::atomic::Ordering;
use std::sync::atomic::{AtomicI32, Ordering};
use std::thread;
use std::time::{Duration, Instant};

View File

@ -8,8 +8,7 @@
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
#![allow(static_mut_refs)]
use std::mem;
use std::ptr;
use std::{mem, ptr};
pub type Key = libc::pthread_key_t;

View File

@ -6,6 +6,11 @@
/// Test direct calls of getrandom 0.1 and 0.2.
fn main() {
let mut data = vec![0; 16];
// Old Solaris had a different return type for `getrandom`, and old versions of the getrandom crate
// used that signature, which Miri is not happy about.
#[cfg(not(target_os = "solaris"))]
getrandom_01::getrandom(&mut data).unwrap();
getrandom_02::getrandom(&mut data).unwrap();
}

View File

@ -2,9 +2,10 @@
//@revisions: with_isolation without_isolation
//@[without_isolation] compile-flags: -Zmiri-disable-isolation
use libc::{getpid, gettid};
use std::thread;
use libc::{getpid, gettid};
fn main() {
thread::spawn(|| {
// Test that in isolation mode a deterministic value will be returned.

View File

@ -5,9 +5,10 @@
#![feature(pointer_is_aligned_to)]
#![feature(strict_provenance)]
use libc::{cpu_set_t, sched_getaffinity, sched_setaffinity};
use std::mem::{size_of, size_of_val};
use libc::{cpu_set_t, sched_getaffinity, sched_setaffinity};
// If pid is zero, then the calling thread is used.
const PID: i32 = 0;

View File

@ -1,7 +1,9 @@
//@ignore-target: windows # File handling is not implemented yet
//@compile-flags: -Zmiri-disable-isolation
use std::{fs::File, io::Error, os::fd::AsRawFd};
use std::fs::File;
use std::io::Error;
use std::os::fd::AsRawFd;
#[path = "../../utils/mod.rs"]
mod utils;

Some files were not shown because too many files have changed in this diff Show More