Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miri subtree update #125005

Merged
merged 39 commits into from
May 11, 2024
Merged
Changes from 4 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0ca3591
unix/fs: a bit of cleanup around host-specific code
RalfJung May 5, 2024
a418b2d
Auto merge of #3573 - RalfJung:fs-cfg, r=RalfJung
bors May 5, 2024
37087db
reduce tokio features
RalfJung May 5, 2024
6a47bd4
remove rand test
RalfJung May 5, 2024
a5baa15
getrandom: test with and without isolation
RalfJung May 5, 2024
629d57e
Auto merge of #3574 - RalfJung:deps, r=RalfJung
bors May 5, 2024
fb84198
solaris support start.
devnexen May 5, 2024
e43458c
Auto merge of #3570 - devnexen:solaris_build_fix, r=RalfJung
bors May 5, 2024
82e2144
avoid code duplication between realloc and malloc
RalfJung May 6, 2024
e477895
Auto merge of #3578 - RalfJung:realloc, r=RalfJung
bors May 6, 2024
43c9916
Implement wcslen
tyilo Apr 16, 2024
3d269e9
Auto merge of #3474 - tyilo:wcslen, r=RalfJung
bors May 6, 2024
dd5437f
organize libc tests into a proper folder, and run some of them on Win…
RalfJung May 6, 2024
4d6d9a9
Auto merge of #3579 - RalfJung:libc, r=RalfJung
bors May 6, 2024
d2472ba
README: update introduction
RalfJung May 7, 2024
34f64cd
remove problems that I do not think we have seen in a while
RalfJung May 7, 2024
720ff0d
Auto merge of #3583 - RalfJung:readme, r=saethlin
bors May 8, 2024
1601b27
io::Error handling: keep around the full io::Error for longer so we c…
RalfJung May 8, 2024
15305a7
Auto merge of #3589 - RalfJung:io-error, r=RalfJung
bors May 8, 2024
4ab79e5
Implement non-null pointer for malloc(0)
tiif May 8, 2024
2e1d417
Auto merge of #3580 - tiif:feat/malloc0-non-null-pointer, r=RalfJung
bors May 8, 2024
6580a22
Allow test targets to be set via CLI args
RossSmyth May 8, 2024
6e564ed
Update CI script for the miri-script test changes
RossSmyth May 8, 2024
620bf34
Update documentation for miri-script test changes
RossSmyth May 8, 2024
d43cb71
minor tweaks
RalfJung May 9, 2024
42d9b68
Auto merge of #3588 - RossSmyth:CliTarget, r=RalfJung
bors May 9, 2024
e16f46c
make MIRI_TEST_TARGET entirely an internal thing
RalfJung May 9, 2024
cb44843
make RUSTC_BLESS entirely an internal thing
RalfJung May 9, 2024
3028864
Auto merge of #3590 - RalfJung:miri-test-target, r=RalfJung
bors May 9, 2024
1edd3d5
do not run symlink tests on Windows hosts
RalfJung May 9, 2024
d3f4d06
Auto merge of #3591 - RalfJung:win-symlink-trouble, r=RalfJung
bors May 9, 2024
25a3b66
rename 'extern-so' to 'native-lib'
RalfJung May 10, 2024
6f4c7d9
Auto merge of #3593 - RalfJung:native-lib, r=RalfJung
bors May 10, 2024
4d63d0a
Preparing for merge from rustc
May 11, 2024
ce3daac
Merge from rustc
May 11, 2024
2427bf9
Auto merge of #3597 - rust-lang:rustup-2024-05-11, r=RalfJung
bors May 11, 2024
7a0ee91
alloc: update comments around malloc() alignment
RalfJung May 11, 2024
01b151e
separate windows heap functions from C heap shims
RalfJung May 11, 2024
79a85d4
Auto merge of #3598 - RalfJung:heap, r=RalfJung
bors May 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 11 additions & 22 deletions src/tools/miri/src/shims/unix/linux/foreign_items.rs
Original file line number Diff line number Diff line change
@@ -117,14 +117,24 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
// `libc::syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), GRND_NONBLOCK)`
// is called if a `HashMap` is created the regular way (e.g. HashMap<K, V>).
id if id == sys_getrandom => {
// Used by getrandom 0.1
// The first argument is the syscall id, so skip over it.
if args.len() < 4 {
throw_ub_format!(
"incorrect number of arguments for `getrandom` syscall: got {}, expected at least 4",
args.len()
);
}
getrandom(this, &args[1], &args[2], &args[3], dest)?;

let ptr = this.read_pointer(&args[1])?;
let len = this.read_target_usize(&args[2])?;
// The only supported flags are GRND_RANDOM and GRND_NONBLOCK,
// neither of which have any effect on our current PRNG.
// See <https://github.com/rust-lang/rust/pull/79196> for a discussion of argument sizes.
let _flags = this.read_scalar(&args[3])?.to_i32();

this.gen_random(ptr, len)?;
this.write_scalar(Scalar::from_target_usize(len, this), dest)?;
}
// `futex` is used by some synchronization primitives.
id if id == sys_futex => {
@@ -196,24 +206,3 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
Ok(EmulateItemResult::NeedsJumping)
}
}

// Shims the linux `getrandom` syscall.
fn getrandom<'tcx>(
this: &mut MiriInterpCx<'_, 'tcx>,
ptr: &OpTy<'tcx, Provenance>,
len: &OpTy<'tcx, Provenance>,
flags: &OpTy<'tcx, Provenance>,
dest: &MPlaceTy<'tcx, Provenance>,
) -> InterpResult<'tcx> {
let ptr = this.read_pointer(ptr)?;
let len = this.read_target_usize(len)?;

// The only supported flags are GRND_RANDOM and GRND_NONBLOCK,
// neither of which have any effect on our current PRNG.
// See <https://github.com/rust-lang/rust/pull/79196> for a discussion of argument sizes.
let _flags = this.read_scalar(flags)?.to_i32();

this.gen_random(ptr, len)?;
this.write_scalar(Scalar::from_target_usize(len, this), dest)?;
Ok(())
}
3 changes: 3 additions & 0 deletions src/tools/miri/src/shims/windows/foreign_items.rs
Original file line number Diff line number Diff line change
@@ -513,6 +513,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
throw_machine_stop!(TerminationInfo::Exit { code: code.into(), leak_check: false });
}
"SystemFunction036" => {
// used by getrandom 0.1
// This is really 'RtlGenRandom'.
let [ptr, len] =
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
@@ -522,6 +523,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
this.write_scalar(Scalar::from_bool(true), dest)?;
}
"ProcessPrng" => {
// used by `std`
let [ptr, len] =
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
let ptr = this.read_pointer(ptr)?;
@@ -530,6 +532,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
this.write_scalar(Scalar::from_i32(1), dest)?;
}
"BCryptGenRandom" => {
// used by getrandom 0.2
let [algorithm, ptr, len, flags] =
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
let algorithm = this.read_scalar(algorithm)?;
115 changes: 0 additions & 115 deletions src/tools/miri/test_dependencies/Cargo.lock
Original file line number Diff line number Diff line change
@@ -17,12 +17,6 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"

[[package]]
name = "autocfg"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"

[[package]]
name = "backtrace"
version = "0.3.71"
@@ -50,12 +44,6 @@ version = "3.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"

[[package]]
name = "bytes"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"

[[package]]
name = "cc"
version = "1.0.96"
@@ -141,16 +129,6 @@ version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"

[[package]]
name = "lock_api"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
dependencies = [
"autocfg",
"scopeguard",
]

[[package]]
name = "log"
version = "0.4.21"
@@ -192,7 +170,6 @@ dependencies = [
"libc",
"num_cpus",
"page_size",
"rand",
"tempfile",
"tokio",
"windows-sys 0.52.0",
@@ -233,41 +210,12 @@ dependencies = [
"winapi",
]

[[package]]
name = "parking_lot"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb"
dependencies = [
"lock_api",
"parking_lot_core",
]

[[package]]
name = "parking_lot_core"
version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets 0.52.5",
]

[[package]]
name = "pin-project-lite"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"

[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"

[[package]]
name = "proc-macro2"
version = "1.0.81"
@@ -286,45 +234,6 @@ dependencies = [
"proc-macro2",
]

[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
]

[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]

[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom 0.2.14",
]

[[package]]
name = "redox_syscall"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e"
dependencies = [
"bitflags",
]

[[package]]
name = "rustc-demangle"
version = "0.1.23"
@@ -344,27 +253,6 @@ dependencies = [
"windows-sys 0.52.0",
]

[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"

[[package]]
name = "signal-hook-registry"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
dependencies = [
"libc",
]

[[package]]
name = "smallvec"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"

[[package]]
name = "socket2"
version = "0.5.7"
@@ -405,13 +293,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787"
dependencies = [
"backtrace",
"bytes",
"libc",
"mio",
"num_cpus",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2",
"tokio-macros",
"windows-sys 0.48.0",
3 changes: 1 addition & 2 deletions src/tools/miri/test_dependencies/Cargo.toml
Original file line number Diff line number Diff line change
@@ -15,11 +15,10 @@ tempfile = "3"

getrandom_01 = { package = "getrandom", version = "0.1" }
getrandom_02 = { package = "getrandom", version = "0.2", features = ["js"] }
rand = { version = "0.8", features = ["small_rng"] }

[target.'cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))'.dependencies]
page_size = "0.6"
tokio = { version = "1.24", features = ["full"] }
tokio = { version = "1.24", features = ["macros", "rt-multi-thread", "time", "net"] }

[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.52", features = [ "Win32_Foundation", "Win32_System_Threading" ] }
3 changes: 2 additions & 1 deletion src/tools/miri/tests/pass-dep/getrandom.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// mac-os `getrandom_01` does some pointer shenanigans
//@compile-flags: -Zmiri-permissive-provenance
//@revisions: isolation no_isolation
//@[no_isolation]compile-flags: -Zmiri-disable-isolation

/// Test direct calls of getrandom 0.1 and 0.2.
/// Make sure they work even with isolation enabled (i.e., we do not hit a file-based fallback path).
fn main() {
let mut data = vec![0; 16];
getrandom_01::getrandom(&mut data).unwrap();
23 changes: 0 additions & 23 deletions src/tools/miri/tests/pass-dep/rand.rs

This file was deleted.