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 #125580

Merged
merged 36 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
37a37f6
Use `throw_unsup_format` instead of returning `ENOTSUP` in the mmap shim
marc0246 May 20, 2024
41c006e
Auto merge of #3610 - marc0246:missing-error-kinds, r=RalfJung
bors May 20, 2024
24138f0
Preparing for merge from rustc
RalfJung May 22, 2024
a1bc030
Merge from rustc
RalfJung May 22, 2024
abbe244
clippy
RalfJung May 22, 2024
7fd1429
Auto merge of #3623 - RalfJung:rustup, r=RalfJung
bors May 22, 2024
3f638a9
solaris/illumos localtime_r / clock_getime support enabled.
devnexen May 18, 2024
04a9a1a
Auto merge of #3614 - devnexen:illumos_time_support, r=oli-obk
bors May 22, 2024
807a0f8
Preparing for merge from rustc
May 23, 2024
f1ffb8d
Merge from rustc
May 23, 2024
400835f
fmt
May 23, 2024
6ea763b
Auto merge of #3624 - rust-lang:rustup-2024-05-23, r=RalfJung
bors May 23, 2024
56c363b
fix alloc_bytes (always allocate at least 1B)
Strophox May 23, 2024
1b374df
differentiate between layout and alloc_layout
Strophox May 23, 2024
7f5e0aa
solaris add suport for threadname.
devnexen May 23, 2024
9ce95c3
Preparing for merge from rustc
May 24, 2024
debf88a
Merge from rustc
May 24, 2024
4763eaf
fmt
May 24, 2024
10d4140
Auto merge of #3627 - rust-lang:rustup-2024-05-24, r=RalfJung
bors May 24, 2024
561bd9a
add back some tokio features
RalfJung May 24, 2024
88d519f
Auto merge of #3628 - RalfJung:tokio, r=RalfJung
bors May 24, 2024
b84620f
extend comments
RalfJung May 24, 2024
7fc41d1
Auto merge of #3625 - Strophox:miri-allocation-fix, r=RalfJung
bors May 24, 2024
008f6b3
Auto merge of #3626 - devnexen:pthread_name_illumos, r=oli-obk
bors May 24, 2024
3cfcfbf
Preparing for merge from rustc
May 25, 2024
1d0ad04
Merge from rustc
May 25, 2024
331bb3f
Auto merge of #3630 - rust-lang:rustup-2024-05-25, r=saethlin
bors May 25, 2024
5fa30f7
make release_clock always work on the current thread
RalfJung May 26, 2024
a131243
completely refactor how we manage blocking and unblocking threads
RalfJung May 26, 2024
e6bb468
data_race: vector indices can be reused immediately when the thread i…
RalfJung May 26, 2024
cbec128
fix './miri run --dep --target _'
RalfJung May 26, 2024
e09bf56
Auto merge of #3633 - RalfJung:target, r=RalfJung
bors May 26, 2024
350f5c8
unix/fs: a bit of cleanup in macos_fbsd_readdir_r
RalfJung May 26, 2024
8e861c6
Auto merge of #3632 - RalfJung:readdir, r=RalfJung
bors May 26, 2024
2e89443
add a macro to declare thread unblock callbacks
RalfJung May 26, 2024
0963353
Auto merge of #3631 - RalfJung:blocking-refactor, r=RalfJung
bors May 26, 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
4 changes: 2 additions & 2 deletions src/tools/miri/ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ case $HOST_TARGET in
UNIX="panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there
TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname libc-time fs
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname libc-time fs
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX pthread-sync
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX pthread-sync
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX threadname pthread-sync libc-time
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX threadname pthread-sync libc-time
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX
TEST_TARGET=wasm32-wasip2 run_tests_minimal empty_main wasm heap_alloc libc-mem
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal empty_main wasm
Expand Down
8 changes: 7 additions & 1 deletion src/tools/miri/miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,13 @@ impl Command {
};
cmd.set_quiet(!verbose);
// Add Miri flags
let cmd = cmd.args(&miri_flags).args(&seed_flag).args(&early_flags).args(&flags);
let mut cmd = cmd.args(&miri_flags).args(&seed_flag).args(&early_flags).args(&flags);
// For `--dep` we also need to set the env var.
if dep {
if let Some(target) = &target {
cmd = cmd.env("MIRI_TEST_TARGET", target);
}
}
// And run the thing.
Ok(cmd.run()?)
};
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6579ed89f0fcc26da71afdd11d30d63f6f812a0a
21e6de7eb64c09102de3f100420a09edc1a2a8d7
14 changes: 5 additions & 9 deletions src/tools/miri/src/alloc_addresses/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,10 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
size,
align,
memory_kind,
ecx.get_active_thread(),
ecx.active_thread(),
) {
if let Some(clock) = clock
&& let Some(data_race) = &ecx.machine.data_race
{
data_race.acquire_clock(&clock, ecx.get_active_thread());
if let Some(clock) = clock {
ecx.acquire_clock(&clock);
}
reuse_addr
} else {
Expand Down Expand Up @@ -369,12 +367,10 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
// `alloc_id_from_addr` any more.
global_state.exposed.remove(&dead_id);
// Also remember this address for future reuse.
let thread = self.threads.get_active_thread_id();
let thread = self.threads.active_thread();
global_state.reuse.add_addr(rng, addr, size, align, kind, thread, || {
if let Some(data_race) = &self.data_race {
data_race
.release_clock(thread, self.threads.active_thread_ref().current_span())
.clone()
data_race.release_clock(&self.threads).clone()
} else {
VClock::default()
}
Expand Down
46 changes: 24 additions & 22 deletions src/tools/miri/src/alloc_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ pub struct MiriAllocBytes {
layout: alloc::Layout,
/// Pointer to the allocation contents.
/// Invariant:
/// * If `self.layout.size() == 0`, then `self.ptr` is some suitably aligned pointer
/// without provenance (and no actual memory was allocated).
/// * If `self.layout.size() == 0`, then `self.ptr` was allocated with the equivalent layout with size 1.
/// * Otherwise, `self.ptr` points to memory allocated with `self.layout`.
ptr: *mut u8,
}
Expand All @@ -30,10 +29,15 @@ impl Clone for MiriAllocBytes {

impl Drop for MiriAllocBytes {
fn drop(&mut self) {
if self.layout.size() != 0 {
// SAFETY: Invariant, `self.ptr` points to memory allocated with `self.layout`.
unsafe { alloc::dealloc(self.ptr, self.layout) }
}
// We have to reconstruct the actual layout used for allocation.
// (`Deref` relies on `size` so we can't just always set it to at least 1.)
let alloc_layout = if self.layout.size() == 0 {
Layout::from_size_align(1, self.layout.align()).unwrap()
} else {
self.layout
};
// SAFETY: Invariant, `self.ptr` points to memory allocated with `self.layout`.
unsafe { alloc::dealloc(self.ptr, alloc_layout) }
}
}

Expand All @@ -56,27 +60,25 @@ impl std::ops::DerefMut for MiriAllocBytes {
}

impl MiriAllocBytes {
/// This method factors out how a `MiriAllocBytes` object is allocated,
/// specifically given an allocation function `alloc_fn`.
/// `alloc_fn` is only used if `size != 0`.
/// Returns `Err(layout)` if the allocation function returns a `ptr` that is `ptr.is_null()`.
/// This method factors out how a `MiriAllocBytes` object is allocated, given a specific allocation function.
/// If `size == 0` we allocate using a different `alloc_layout` with `size = 1`, to ensure each allocation has a unique address.
/// Returns `Err(alloc_layout)` if the allocation function returns a `ptr` where `ptr.is_null()`.
fn alloc_with(
size: usize,
align: usize,
alloc_fn: impl FnOnce(Layout) -> *mut u8,
) -> Result<MiriAllocBytes, Layout> {
let layout = Layout::from_size_align(size, align).unwrap();
let ptr = if size == 0 {
std::ptr::without_provenance_mut(align)
// When size is 0 we allocate 1 byte anyway, to ensure each allocation has a unique address.
let alloc_layout =
if size == 0 { Layout::from_size_align(1, align).unwrap() } else { layout };
let ptr = alloc_fn(alloc_layout);
if ptr.is_null() {
Err(alloc_layout)
} else {
let ptr = alloc_fn(layout);
if ptr.is_null() {
return Err(layout);
}
ptr
};
// SAFETY: All `MiriAllocBytes` invariants are fulfilled.
Ok(Self { ptr, layout })
// SAFETY: All `MiriAllocBytes` invariants are fulfilled.
Ok(Self { ptr, layout })
}
}
}

Expand All @@ -85,7 +87,7 @@ impl AllocBytes for MiriAllocBytes {
let slice = slice.into();
let size = slice.len();
let align = align.bytes_usize();
// SAFETY: `alloc_fn` will only be used if `size != 0`.
// SAFETY: `alloc_fn` will only be used with `size != 0`.
let alloc_fn = |layout| unsafe { alloc::alloc(layout) };
let alloc_bytes = MiriAllocBytes::alloc_with(size, align, alloc_fn)
.unwrap_or_else(|layout| alloc::handle_alloc_error(layout));
Expand All @@ -98,7 +100,7 @@ impl AllocBytes for MiriAllocBytes {
fn zeroed(size: Size, align: Align) -> Option<Self> {
let size = size.bytes_usize();
let align = align.bytes_usize();
// SAFETY: `alloc_fn` will only be used if `size != 0`.
// SAFETY: `alloc_fn` will only be used with `size != 0`.
let alloc_fn = |layout| unsafe { alloc::alloc_zeroed(layout) };
MiriAllocBytes::alloc_with(size, align, alloc_fn).ok()
}
Expand Down
13 changes: 7 additions & 6 deletions src/tools/miri/src/borrow_tracker/tree_borrows/perms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum PermissionPriv {
/// is relevant
/// - `conflicted` is set on foreign reads,
/// - `conflicted` must not be set on child writes (there is UB otherwise).
///
/// This is so that the behavior of `Reserved` adheres to the rules of `noalias`:
/// - foreign-read then child-write is UB due to `conflicted`,
/// - child-write then foreign-read is UB since child-write will activate and then
Expand Down Expand Up @@ -339,15 +340,15 @@ pub mod diagnostics {
/// This function assumes that its arguments apply to the same location
/// and that they were obtained during a normal execution. It will panic otherwise.
/// - all transitions involved in `self` and `err` should be increasing
/// (Reserved < Active < Frozen < Disabled);
/// (Reserved < Active < Frozen < Disabled);
/// - between `self` and `err` the permission should also be increasing,
/// so all permissions inside `err` should be greater than `self.1`;
/// so all permissions inside `err` should be greater than `self.1`;
/// - `Active` and `Reserved(conflicted=false)` cannot cause an error
/// due to insufficient permissions, so `err` cannot be a `ChildAccessForbidden(_)`
/// of either of them;
/// due to insufficient permissions, so `err` cannot be a `ChildAccessForbidden(_)`
/// of either of them;
/// - `err` should not be `ProtectedDisabled(Disabled)`, because the protected
/// tag should not have been `Disabled` in the first place (if this occurs it means
/// we have unprotected tags that become protected)
/// tag should not have been `Disabled` in the first place (if this occurs it means
/// we have unprotected tags that become protected)
pub(in super::super) fn is_relevant(&self, err: TransitionError) -> bool {
// NOTE: `super::super` is the visibility of `TransitionError`
assert!(self.is_possible());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ mod spurious_read {
/// - any access to the same location
/// - end of one of them being protected
/// - a retag that would change their relative position
///
/// The type `TestEvent` models these kinds of events.
///
/// In order to prevent `x` or `y` from losing their protector,
Expand Down
Loading
Loading