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

View File

@ -12,9 +12,6 @@ on:
schedule: schedule:
- cron: '44 4 * * *' # At 4:44 UTC every day. - cron: '44 4 * * *' # At 4:44 UTC every day.
permissions:
contents: write
defaults: defaults:
run: run:
shell: bash shell: bash
@ -90,6 +87,11 @@ jobs:
cron-fail-notify: cron-fail-notify:
name: cronjob failure notification name: cronjob failure notification
runs-on: ubuntu-latest 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] needs: [build, style]
if: github.event_name == 'schedule' && failure() if: github.event_name == 'schedule' && failure()
steps: steps:

View File

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

View File

@ -25,7 +25,7 @@ aes = { version = "0.8.3", features = ["hazmat"] }
measureme = "11" measureme = "11"
ctrlc = "3.2.5" ctrlc = "3.2.5"
chrono = { version = "0.4.38", default-features = false } chrono = { version = "0.4.38", default-features = false }
chrono-tz = "0.9" chrono-tz = "0.10"
directories = "5" directories = "5"
# Copied from `compiler/rustc/Cargo.toml`. # 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`. - `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`. - `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. - `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. - 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 However, even for targets that we do support, the degree of support for accessing platform APIs

View File

@ -41,9 +41,12 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.73" version = "1.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0"
dependencies = [
"shlex",
]
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -92,3 +95,9 @@ name = "rustc-demangle"
version = "0.1.21" version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" 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 //! Extracted from the backtrace crate's test test_frame_conversion
use backtrace::{Backtrace, BacktraceFrame};
use std::fmt::Write; use std::fmt::Write;
use backtrace::{Backtrace, BacktraceFrame};
fn main() { fn main() {
let mut frames = vec![]; let mut frames = vec![];
backtrace::trace(|frame| { backtrace::trace(|frame| {

File diff suppressed because one or more lines are too long

View File

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

View File

@ -18,7 +18,7 @@ directories = "5"
rustc_version = "0.4" rustc_version = "0.4"
serde_json = "1.0.40" serde_json = "1.0.40"
cargo_metadata = "0.18.0" 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 # Enable some feature flags that dev-dependencies need but dependencies
# do not. This makes `./miri install` after `./miri build` faster. # 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 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 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 { match phase {
RunnerPhase::Rustdoc => { RunnerPhase::Rustdoc => {
cmd.stdin(std::process::Stdio::piped()); 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 mut child = cmd.spawn().expect("failed to spawn process");
let child_stdin = child.stdin.take().unwrap(); let child_stdin = child.stdin.take().unwrap();
// Write stdin in a background thread, as it may block. // 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=arm-unknown-linux-gnueabi run_tests
TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture of choice TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture of choice
# Partially supported targets (tier 2) # 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) BASIC="empty_main integer heap_alloc libc-mem vec string btreemap" # ensures we have the basics: pre-main code, system allocator
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 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 threadname pthread time fs 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 threadname pthread time 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 thread sync available-parallelism time tls 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 thread sync available-parallelism time 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 pthread --skip threadname --skip pthread_cond_timedwait TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap pthread --skip threadname
TEST_TARGET=wasm32-wasip2 run_tests_minimal empty_main wasm heap_alloc libc-mem TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal empty_main 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 TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
# Custom target JSON file # 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) i686-pc-windows-msvc)
# Host # Host

View File

@ -8,12 +8,6 @@ version = "1.0.80"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "2.4.2" version = "2.4.2"
@ -112,13 +106,12 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]] [[package]]
name = "libredox" name = "libredox"
version = "0.0.1" version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
dependencies = [ dependencies = [
"bitflags 2.4.2", "bitflags",
"libc", "libc",
"redox_syscall",
] ]
[[package]] [[package]]
@ -150,12 +143,6 @@ dependencies = [
"xshell", "xshell",
] ]
[[package]]
name = "once_cell"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]] [[package]]
name = "option-ext" name = "option-ext"
version = "0.2.0" version = "0.2.0"
@ -186,20 +173,11 @@ dependencies = [
"proc-macro2", "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]] [[package]]
name = "redox_users" name = "redox_users"
version = "0.4.4" version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
dependencies = [ dependencies = [
"getrandom", "getrandom",
"libredox", "libredox",
@ -221,7 +199,7 @@ version = "0.38.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
dependencies = [ dependencies = [
"bitflags 2.4.2", "bitflags",
"errno", "errno",
"libc", "libc",
"linux-raw-sys", "linux-raw-sys",
@ -342,47 +320,25 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]] [[package]]
name = "which" name = "which"
version = "4.4.2" version = "6.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f"
dependencies = [ dependencies = [
"either", "either",
"home", "home",
"once_cell",
"rustix", "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]] [[package]]
name = "winapi-util" name = "winapi-util"
version = "0.1.6" version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [ 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]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.48.0" version = "0.48.0"
@ -522,6 +478,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winsafe"
version = "0.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"
[[package]] [[package]]
name = "xshell" name = "xshell"
version = "0.2.6" 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. # This is needed to make this package build on stable when the parent package uses unstable cargo features.
[dependencies] [dependencies]
which = "4.4" which = "6.0"
walkdir = "2.3" walkdir = "2.3"
itertools = "0.11" itertools = "0.11"
path_macro = "1.0" path_macro = "1.0"

View File

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

View File

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

View File

@ -1 +1 @@
6ce376774c0bc46ac8be247bca93ff5a1287a8fc 76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146

View File

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

View File

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

View File

@ -1,10 +1,10 @@
//! Manages a pool of addresses that can be reused. //! Manages a pool of addresses that can be reused.
use rand::Rng; use rand::Rng;
use rustc_target::abi::{Align, Size}; 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; const MAX_POOL_SIZE: usize = 64;

View File

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

View File

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

View File

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

View File

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

View File

@ -6,25 +6,24 @@ mod item;
mod stack; mod stack;
use std::cell::RefCell; use std::cell::RefCell;
use std::cmp;
use std::fmt::Write; use std::fmt::Write;
use std::mem; use std::{cmp, mem};
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_middle::mir::{Mutability, RetagKind}; 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 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}; use self::diagnostics::{RetagCause, RetagInfo};
pub use self::item::{Item, Permission}; pub use self::item::{Item, Permission};
pub use self::stack::Stack; 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; pub type AllocState = Stacks;
@ -171,7 +170,7 @@ impl NewPermission {
/// F2b: No `SharedReadWrite` or `Unique` will ever be added on top of our `SharedReadOnly`. /// F2b: No `SharedReadWrite` or `Unique` will ever be added on top of our `SharedReadOnly`.
/// F3: If an access happens with an `&` outside `UnsafeCell`, /// F3: If an access happens with an `&` outside `UnsafeCell`,
/// it requires the `SharedReadOnly` to still be in the stack. /// it requires the `SharedReadOnly` to still be in the stack.
///
/// Core relation on `Permission` to define which accesses are allowed /// Core relation on `Permission` to define which accesses are allowed
impl Permission { impl Permission {
/// This defines for a given permission, whether it permits the given kind of access. /// 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 tracing::trace;
use crate::ProvenanceExtra; use crate::ProvenanceExtra;
use crate::borrow_tracker::{ use crate::borrow_tracker::stacked_borrows::{Item, Permission};
AccessKind, BorTag, use crate::borrow_tracker::{AccessKind, BorTag};
stacked_borrows::{Item, Permission},
};
/// Exactly what cache size we should use is a difficult trade-off. There will always be some /// 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 /// 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 rustc_span::{Span, SpanData};
use crate::borrow_tracker::ProtectorKind; use crate::borrow_tracker::ProtectorKind;
use crate::borrow_tracker::tree_borrows::{ use crate::borrow_tracker::tree_borrows::perms::{PermTransition, Permission};
perms::{PermTransition, Permission}, use crate::borrow_tracker::tree_borrows::tree::LocationState;
tree::LocationState, use crate::borrow_tracker::tree_borrows::unimap::UniIndex;
unimap::UniIndex,
};
use crate::*; use crate::*;
/// Cause of an access: either a real access or one /// Cause of an access: either a real access or one

View File

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

View File

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

View File

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

View File

@ -12,7 +12,8 @@
#![allow(dead_code)] #![allow(dead_code)]
use std::{hash::Hash, mem}; use std::hash::Hash;
use std::mem;
use rustc_data_structures::fx::FxHashMap; 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 //! code some atomic operations may increment the timestamp when not necessary but this has no effect
//! on the data-race detection code. //! on the data-race detection code.
use std::{ use std::cell::{Cell, Ref, RefCell, RefMut};
cell::{Cell, Ref, RefCell, RefMut}, use std::fmt::Debug;
fmt::Debug, use std::mem;
mem,
};
use rustc_ast::Mutability; use rustc_ast::Mutability;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::fx::FxHashSet;
use rustc_index::{Idx, IndexVec}; 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_span::Span;
use rustc_target::abi::{Align, HasDataLayout, Size}; 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::diagnostics::RacingOp;
use crate::*; use crate::*;
use super::{
vector_clock::{VClock, VTimestamp, VectorIdx},
weak_memory::EvalContextExt as _,
};
pub type AllocState = VClockAlloc; pub type AllocState = VClockAlloc;
/// Valid atomic read-write orderings, alias of atomic::Ordering (not non-exhaustive). /// 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 //! 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 //! 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 std::ops::{Index, IndexMut, Range};
use rustc_const_eval::interpret::AllocRange; use rustc_const_eval::interpret::AllocRange;
use rustc_target::abi::Size;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
struct Elem<T> { struct Elem<T> {

View File

@ -1,5 +1,6 @@
use std::any::Any; 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::ops::Not;
use std::time::Duration; 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 /// 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 std::time::{Duration, SystemTime};
use either::Either; use either::Either;
use rustc_const_eval::CTRL_C_RECEIVED; use rustc_const_eval::CTRL_C_RECEIVED;
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_hir::def_id::DefId; 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, // https://github.com/rust-lang/miri/issues/1763). In this case,
// just do nothing, which effectively just returns to the // just do nothing, which effectively just returns to the
// scheduler. // scheduler.
return Ok(()); Ok(())
} }
#[inline] #[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_index::Idx;
use rustc_span::{DUMMY_SP, Span, SpanData}; use rustc_span::{DUMMY_SP, Span, SpanData};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::{
cmp::Ordering,
fmt::Debug,
ops::{Index, Shr},
};
use super::data_race::NaReadType; use super::data_race::NaReadType;
@ -430,10 +429,12 @@ impl Index<VectorIdx> for VClock {
/// test suite /// test suite
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::cmp::Ordering;
use rustc_span::DUMMY_SP;
use super::{VClock, VTimestamp, VectorIdx}; use super::{VClock, VTimestamp, VectorIdx};
use crate::concurrency::data_race::NaReadType; use crate::concurrency::data_race::NaReadType;
use rustc_span::DUMMY_SP;
use std::cmp::Ordering;
#[test] #[test]
fn test_equal() { fn test_equal() {

View File

@ -76,21 +76,16 @@
// (https://github.com/ChrisLidbury/tsan11/blob/ecbd6b81e9b9454e01cba78eb9d88684168132c7/lib/tsan/rtl/tsan_relaxed.cc#L295) // (https://github.com/ChrisLidbury/tsan11/blob/ecbd6b81e9b9454e01cba78eb9d88684168132c7/lib/tsan/rtl/tsan_relaxed.cc#L295)
// and here. // and here.
use std::{ use std::cell::{Ref, RefCell};
cell::{Ref, RefCell}, use std::collections::VecDeque;
collections::VecDeque,
};
use rustc_data_structures::fx::FxHashMap; 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 crate::*;
use super::{
data_race::{GlobalState as DataRaceState, ThreadClockSet},
range_object_map::{AccessType, RangeObjectMap},
vector_clock::{VClock, VTimestamp, VectorIdx},
};
pub type AllocState = StoreBufferAlloc; pub type AllocState = StoreBufferAlloc;
// Each store buffer must be bounded otherwise it will grow indefinitely. // 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. //! Main evaluator loop and setting up the initial stack frame.
use std::ffi::{OsStr, OsString}; use std::ffi::{OsStr, OsString};
use std::iter;
use std::panic::{self, AssertUnwindSafe}; use std::panic::{self, AssertUnwindSafe};
use std::path::PathBuf; use std::path::PathBuf;
use std::task::Poll; 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_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir::def::Namespace; use rustc_hir::def::Namespace;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_middle::ty::{ use rustc_middle::ty::layout::{LayoutCx, LayoutOf};
self, Ty, TyCtxt, use rustc_middle::ty::{self, Ty, TyCtxt};
layout::{LayoutCx, LayoutOf}, use rustc_session::config::EntryFnType;
};
use rustc_target::spec::abi::Abi; 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::shims::tls;
use crate::*; use crate::*;

View File

@ -1,29 +1,22 @@
use std::cmp;
use std::collections::BTreeSet; use std::collections::BTreeSet;
use std::iter;
use std::num::NonZero; use std::num::NonZero;
use std::sync::Mutex; use std::sync::Mutex;
use std::time::Duration; use std::time::Duration;
use std::{cmp, iter};
use rand::RngCore; use rand::RngCore;
use rustc_apfloat::Float; use rustc_apfloat::Float;
use rustc_apfloat::ieee::{Double, Half, Quad, Single}; use rustc_apfloat::ieee::{Double, Half, Quad, Single};
use rustc_hir::{ use rustc_hir::Safety;
Safety, use rustc_hir::def::{DefKind, Namespace};
def::{DefKind, Namespace}, use rustc_hir::def_id::{CRATE_DEF_INDEX, CrateNum, DefId, LOCAL_CRATE};
def_id::{CRATE_DEF_INDEX, CrateNum, DefId, LOCAL_CRATE},
};
use rustc_index::IndexVec; use rustc_index::IndexVec;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::middle::exported_symbols::ExportedSymbol; use rustc_middle::middle::exported_symbols::ExportedSymbol;
use rustc_middle::mir; use rustc_middle::mir;
use rustc_middle::ty::layout::{FnAbiOf, MaybeResult}; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, MaybeResult, TyAndLayout};
use rustc_middle::ty::{ use rustc_middle::ty::{self, FloatTy, IntTy, Ty, TyCtxt, UintTy};
self, FloatTy, IntTy, Ty, TyCtxt, UintTy,
layout::{LayoutOf, TyAndLayout},
};
use rustc_session::config::CrateType; use rustc_session::config::CrateType;
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
use rustc_target::abi::{Align, FieldIdx, FieldsShape, Size, Variants}; 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 self::helpers::check_arg_count;
use crate::*;
pub enum AtomicOp { pub enum AtomicOp {
/// The `bool` indicates whether the result of the operation should be negated (`UnOp::Not`, /// 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 rand::Rng;
use rustc_apfloat::{Float, Round}; use rustc_apfloat::{Float, Round};
use rustc_middle::{ use rustc_middle::mir;
mir, use rustc_middle::ty::{self, FloatTy};
ty::{self, FloatTy},
};
use rustc_span::{Symbol, sym}; use rustc_span::{Symbol, sym};
use rustc_target::abi::Size; use rustc_target::abi::Size;
use crate::*;
use self::atomic::EvalContextExt as _; use self::atomic::EvalContextExt as _;
use self::helpers::{ToHost, ToSoft, check_arg_count}; use self::helpers::{ToHost, ToSoft, check_arg_count};
use self::simd::EvalContextExt as _; use self::simd::EvalContextExt as _;
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {

View File

@ -1,8 +1,8 @@
use either::Either; use either::Either;
use rustc_apfloat::{Float, Round}; use rustc_apfloat::{Float, Round};
use rustc_middle::ty::FloatTy;
use rustc_middle::ty::layout::{HasParamEnv, LayoutOf}; 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_span::{Symbol, sym};
use rustc_target::abi::{Endian, HasDataLayout}; use rustc_target::abi::{Endian, HasDataLayout};

View File

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

View File

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

View File

@ -1,5 +1,4 @@
use either::Either; use either::Either;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use crate::*; 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 // and not execute any Miri shim. Somewhat unintuitively doing so is done
// by returning `NotSupported`, which triggers the `lookup_exported_symbol` // by returning `NotSupported`, which triggers the `lookup_exported_symbol`
// fallback case in `emulate_foreign_item`. // fallback case in `emulate_foreign_item`.
return Ok(EmulateItemResult::NotSupported); Ok(EmulateItemResult::NotSupported)
} }
AllocatorKind::Default => { AllocatorKind::Default => {
default(this)?; default(this)?;

View File

@ -1,9 +1,11 @@
use crate::*;
use rustc_ast::ast::Mutability; use rustc_ast::ast::Mutability;
use rustc_middle::ty::layout::LayoutOf as _; use rustc_middle::ty::layout::LayoutOf as _;
use rustc_middle::ty::{self, Instance, Ty}; use rustc_middle::ty::{self, Instance, Ty};
use rustc_span::{BytePos, Loc, Symbol, hygiene}; 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> {} impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'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 rustc_data_structures::fx::FxHashMap;
use self::shims::unix::UnixEnvVars;
use self::shims::windows::WindowsEnvVars;
use crate::*; use crate::*;
use self::shims::{unix::UnixEnvVars, windows::WindowsEnvVars};
#[derive(Default)] #[derive(Default)]
pub enum EnvVars<'tcx> { 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>> { fn get_env_var(&mut self, name: &OsStr) -> InterpResult<'tcx, Option<OsString>> {
let this = self.eval_context_ref(); let this = self.eval_context_ref();
match &this.machine.env_vars { match &this.machine.env_vars {
EnvVars::Uninit => return Ok(None), EnvVars::Uninit => Ok(None),
EnvVars::Unix(vars) => vars.get(this, name), EnvVars::Unix(vars) => vars.get(this, name),
EnvVars::Windows(vars) => vars.get(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_apfloat::Float;
use rustc_ast::expand::allocator::alloc_error_handler_name; 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::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir; use rustc_middle::{mir, ty};
use rustc_middle::ty;
use rustc_span::Symbol; use rustc_span::Symbol;
use rustc_target::{ use rustc_target::abi::{Align, AlignFromBytesError, Size};
abi::{Align, AlignFromBytesError, Size}, use rustc_target::spec::abi::Abi;
spec::abi::Abi,
};
use self::helpers::{ToHost, ToSoft};
use super::alloc::EvalContextExt as _; use super::alloc::EvalContextExt as _;
use super::backtrace::EvalContextExt as _; use super::backtrace::EvalContextExt as _;
use crate::*; use crate::*;
use self::helpers::{ToHost, ToSoft};
/// Type of dynamic symbols (for `dlsym` et al) /// Type of dynamic symbols (for `dlsym` et al)
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]

View File

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

View File

@ -1,11 +1,10 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::ffi::{OsStr, OsString}; use std::ffi::{OsStr, OsString};
use std::path::{Path, PathBuf};
#[cfg(unix)] #[cfg(unix)]
use std::os::unix::ffi::{OsStrExt, OsStringExt}; use std::os::unix::ffi::{OsStrExt, OsStringExt};
#[cfg(windows)] #[cfg(windows)]
use std::os::windows::ffi::{OsStrExt, OsStringExt}; use std::os::windows::ffi::{OsStrExt, OsStringExt};
use std::path::{Path, PathBuf};
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;
use rustc_middle::ty::layout::LayoutOf; 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::PanicStrategy;
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use crate::*;
use self::helpers::check_arg_count; use self::helpers::check_arg_count;
use crate::*;
/// Holds all of the relevant data for when unwinding hits a `try` frame. /// Holds all of the relevant data for when unwinding hits a `try` frame.
#[derive(Debug)] #[derive(Debug)]

View File

@ -36,8 +36,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let mut relative_clocks; let mut relative_clocks;
match this.tcx.sess.target.os.as_ref() { match this.tcx.sess.target.os.as_ref() {
"linux" | "freebsd" => { "linux" | "freebsd" | "android" => {
// Linux and FreeBSD have two main kinds of clocks. REALTIME clocks return the actual time since the // 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. // 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 // 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. // 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::ffi::{OsStr, OsString};
use std::io::ErrorKind; use std::io::ErrorKind;
use std::mem; use std::{env, mem};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;

View File

@ -5,8 +5,7 @@ use std::any::Any;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::io::{self, ErrorKind, IsTerminal, Read, SeekFrom, Write}; use std::io::{self, ErrorKind, IsTerminal, Read, SeekFrom, Write};
use std::ops::Deref; use std::ops::Deref;
use std::rc::Rc; use std::rc::{Rc, Weak};
use std::rc::Weak;
use rustc_target::abi::Size; 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())?; 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. // 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)?; this.write_int(u64::try_from(read_bytes).unwrap(), dest)?;
return Ok(()); Ok(())
} }
Err(e) => { Err(e) => {
this.set_last_error_from_io_error(e)?; this.set_last_error_from_io_error(e)?;
this.write_int(-1, dest)?; 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::abi::Size;
use rustc_target::spec::abi::Abi; 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::android::foreign_items as android;
use self::shims::unix::freebsd::foreign_items as freebsd; use self::shims::unix::freebsd::foreign_items as freebsd;
use self::shims::unix::linux::foreign_items as linux; use self::shims::unix::linux::foreign_items as linux;
use self::shims::unix::macos::foreign_items as macos; use self::shims::unix::macos::foreign_items as macos;
use self::shims::unix::solarish::foreign_items as solarish; 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 { pub fn is_dyn_sym(name: &str, target_os: &str) -> bool {
match name { match name {
@ -792,6 +791,20 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.gen_random(ptr, len)?; this.gen_random(ptr, len)?;
this.write_scalar(Scalar::from_target_usize(len, this), dest)?; 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" => { "_Unwind_RaiseException" => {
// This is not formally part of POSIX, but it is very wide-spread on POSIX systems. // 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: // 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_data_structures::fx::FxHashMap;
use rustc_target::abi::Size; 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::os_str::bytes_to_os_str;
use crate::shims::unix::fd::FileDescriptionRef; use crate::shims::unix::fd::FileDescriptionRef;
use crate::shims::unix::*; use crate::shims::unix::*;
use crate::*; use crate::*;
use self::shims::time::system_time_to_duration;
use self::fd::FlockOp;
#[derive(Debug)] #[derive(Debug)]
struct FileHandle { struct FileHandle {
@ -186,12 +185,14 @@ impl FileDescription for FileHandle {
#[cfg(target_family = "windows")] #[cfg(target_family = "windows")]
{ {
use std::os::windows::io::AsRawHandle; use std::os::windows::io::AsRawHandle;
use windows_sys::Win32::{
Foundation::{ERROR_IO_PENDING, ERROR_LOCK_VIOLATION, FALSE, HANDLE, TRUE}, use windows_sys::Win32::Foundation::{
Storage::FileSystem::{ ERROR_IO_PENDING, ERROR_LOCK_VIOLATION, FALSE, HANDLE, TRUE,
LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, LockFileEx, UnlockFile,
},
}; };
use windows_sys::Win32::Storage::FileSystem::{
LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, LockFileEx, UnlockFile,
};
let fh = self.file.as_raw_handle() as HANDLE; let fh = self.file.as_raw_handle() as HANDLE;
use FlockOp::*; 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 /// list about file descriptors in the interest list that have some
/// events available. Up to `maxevents` are returned by `epoll_wait()`. /// events available. Up to `maxevents` are returned by `epoll_wait()`.
/// The `maxevents` argument must be greater than zero. /// The `maxevents` argument must be greater than zero.
///
/// The `timeout` argument specifies the number of milliseconds that /// The `timeout` argument specifies the number of milliseconds that
/// `epoll_wait()` will block. Time is measured against the /// `epoll_wait()` will block. Time is measured against the
/// CLOCK_MONOTONIC clock. If the timeout is zero, the function will not block, /// CLOCK_MONOTONIC clock. If the timeout is zero, the function will not block,
/// while if the timeout is -1, the function will block /// while if the timeout is -1, the function will block
/// until at least one event has been retrieved (or an error /// until at least one event has been retrieved (or an error
/// occurred). /// occurred).
///
/// A call to `epoll_wait()` will block until either: /// A call to `epoll_wait()` will block until either:
/// • a file descriptor delivers an event; /// • a file descriptor delivers an event;
/// • the call is interrupted by a signal handler; or /// • the call is interrupted by a signal handler; or
/// • the timeout expires. /// • the timeout expires.
///
/// Note that the timeout interval will be rounded up to the system /// Note that the timeout interval will be rounded up to the system
/// clock granularity, and kernel scheduling delays mean that the /// clock granularity, and kernel scheduling delays mean that the
/// blocking interval may overrun by a small amount. Specifying a /// blocking interval may overrun by a small amount. Specifying a
@ -596,7 +596,7 @@ fn ready_list_next(
return Some(epoll_event_instance); return Some(epoll_event_instance);
} }
} }
return None; None
} }
/// This helper function checks whether an epoll notification should be triggered for a specific /// 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); let event_instance = EpollEventInstance::new(flags, epoll_event_interest.data);
// Triggers the notification by inserting it to the ready list. // Triggers the notification by inserting it to the ready list.
ready_list.insert(epoll_key, event_instance); ready_list.insert(epoll_key, event_instance);
return Ok(true); Ok(true)
} else {
Ok(false)
} }
return Ok(false);
} }
/// Callback function after epoll_wait unblocks /// Callback function after epoll_wait unblocks

View File

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

View File

@ -1,14 +1,13 @@
use rustc_span::Symbol; use rustc_span::Symbol;
use rustc_target::spec::abi::Abi; 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::epoll::EvalContextExt as _;
use self::shims::unix::linux::eventfd::EvalContextExt as _; use self::shims::unix::linux::eventfd::EvalContextExt as _;
use self::shims::unix::linux::mem::EvalContextExt as _; use self::shims::unix::linux::mem::EvalContextExt as _;
use self::shims::unix::linux::sync::futex; 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 { pub fn is_dyn_sym(name: &str) -> bool {
matches!(name, "statx") 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 //! This follows the pattern in src/shims/unix/mem.rs: We only support uses of mremap that would
//! correspond to valid uses of realloc. //! correspond to valid uses of realloc.
use crate::*;
use rustc_target::abi::Size; use rustc_target::abi::Size;
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn mremap( fn mremap(

View File

@ -80,7 +80,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
// Random data generation // Random data generation
"CCRandomGenerateBytes" => { "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 bytes = this.read_pointer(bytes)?;
let count = this.read_target_usize(count)?; let count = this.read_target_usize(count)?;
let success = this.eval_libc_i32("kCCSuccess"); 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 //! munmap shim which would partially unmap a region of address space previously mapped by mmap will
//! report UB. //! report UB.
use crate::*;
use rustc_target::abi::Size; use rustc_target::abi::Size;
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {} impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn mmap( fn mmap(

View File

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

View File

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

View File

@ -9,10 +9,11 @@ use std::io::{Error, ErrorKind, Read};
use rustc_target::abi::Size; use rustc_target::abi::Size;
use crate::concurrency::VClock;
use crate::shims::unix::fd::{FileDescriptionRef, WeakFileDescriptionRef}; use crate::shims::unix::fd::{FileDescriptionRef, WeakFileDescriptionRef};
use crate::shims::unix::linux::epoll::{EpollReadyEvents, EvalContextExt as _}; use crate::shims::unix::linux::epoll::{EpollReadyEvents, EvalContextExt as _};
use crate::shims::unix::*; use crate::shims::unix::*;
use crate::{concurrency::VClock, *}; use crate::*;
/// The maximum capacity of the socketpair buffer in bytes. /// The maximum capacity of the socketpair buffer in bytes.
/// This number is arbitrary as the value can always /// 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 rustc_data_structures::fx::FxHashMap;
use crate::*;
use self::helpers::windows_check_buffer_size; use self::helpers::windows_check_buffer_size;
use crate::*;
#[derive(Default)] #[derive(Default)]
pub struct WindowsEnvVars { pub struct WindowsEnvVars {

View File

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

View File

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

View File

@ -5,9 +5,8 @@ mod handle;
mod sync; mod sync;
mod thread; mod thread;
pub use self::env::WindowsEnvVars;
// All the Windows-specific extension traits // 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::handle::EvalContextExt as _;
pub use self::sync::EvalContextExt as _; pub use self::sync::EvalContextExt as _;
pub use self::thread::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( fn InitOnceComplete(

View File

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

View File

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

View File

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

View File

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

View File

@ -52,9 +52,12 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.1.7" version = "1.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0"
dependencies = [
"shlex",
]
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -261,6 +264,12 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]] [[package]]
name = "signal-hook-registry" name = "signal-hook-registry"
version = "1.4.2" 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. // Joining the same thread from multiple threads is undefined behavior.
use std::thread; use std::{mem, ptr, thread};
use std::{mem, ptr};
extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { 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. // 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 //@compile-flags: -Zmiri-disable-isolation -Zmiri-num-cpus=4
fn main() { fn main() {
use libc::{cpu_set_t, sched_setaffinity};
use std::mem::size_of; use std::mem::size_of;
use libc::{cpu_set_t, sched_setaffinity};
// If pid is zero, then the calling thread is used. // If pid is zero, then the calling thread is used.
const PID: i32 = 0; const PID: i32 = 0;

View File

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

View File

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

View File

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

View File

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

View File

@ -3,8 +3,7 @@
// Avoid accidental synchronization via address reuse inside `thread::spawn`. // Avoid accidental synchronization via address reuse inside `thread::spawn`.
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0 //@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
use std::sync::atomic::AtomicUsize; use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::atomic::Ordering;
use std::thread::spawn; use std::thread::spawn;
#[derive(Copy, Clone)] #[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)] #![feature(ptr_internals)]
use core::ptr::Unique; use core::ptr::{Unique, addr_of_mut};
use core::ptr::addr_of_mut;
fn main() { fn main() {
let mut data = 0u8; 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 { impl<T: Copy> Trait for T {
type Assoc = T; type Assoc = T;
fn foo(&self) -> T { *self } fn foo(&self) -> T {
*self
}
} }
fn main() { fn main() {

View File

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

View File

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

View File

@ -6,6 +6,11 @@
/// Test direct calls of getrandom 0.1 and 0.2. /// Test direct calls of getrandom 0.1 and 0.2.
fn main() { fn main() {
let mut data = vec![0; 16]; 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_01::getrandom(&mut data).unwrap();
getrandom_02::getrandom(&mut data).unwrap(); getrandom_02::getrandom(&mut data).unwrap();
} }

View File

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

View File

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

View File

@ -1,7 +1,9 @@
//@ignore-target: windows # File handling is not implemented yet //@ignore-target: windows # File handling is not implemented yet
//@compile-flags: -Zmiri-disable-isolation //@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"] #[path = "../../utils/mod.rs"]
mod utils; mod utils;

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