Skip to content

Commit 3358569

Browse files
authored
Merge pull request #4541 from rust-lang/rustup-2025-08-24
Automatic Rustup
2 parents 3ad93a5 + 98330fa commit 3358569

File tree

7 files changed

+102
-10
lines changed

7 files changed

+102
-10
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8e3710ef31a0b2cdf5a1c2f3929b7735d1e28c20
1+
f6d23413c399fb530be362ebcf25a4e788e16137

src/machine.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1616
#[allow(unused)]
1717
use rustc_data_structures::static_assert_size;
1818
use rustc_hir::attrs::InlineAttr;
19+
use rustc_middle::middle::codegen_fn_attrs::TargetFeatureKind;
1920
use rustc_middle::mir;
2021
use rustc_middle::query::TyCtxtAt;
2122
use rustc_middle::ty::layout::{
@@ -1076,7 +1077,8 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
10761077
.target_features
10771078
.iter()
10781079
.filter(|&feature| {
1079-
!feature.implied && !ecx.tcx.sess.target_features.contains(&feature.name)
1080+
feature.kind != TargetFeatureKind::Implied
1081+
&& !ecx.tcx.sess.target_features.contains(&feature.name)
10801082
})
10811083
.fold(String::new(), |mut s, feature| {
10821084
if !s.is_empty() {

src/shims/native_lib/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,9 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
242242

243243
match evt {
244244
AccessEvent::Read(_) => {
245-
// FIXME: ProvenanceMap should have something like get_range().
246-
let p_map = alloc.provenance();
247-
for idx in overlap {
248-
// If a provenance was read by the foreign code, expose it.
249-
if let Some((prov, _idx)) = p_map.get_byte(Size::from_bytes(idx), this)
250-
{
251-
this.expose_provenance(prov)?;
252-
}
245+
// If a provenance was read by the foreign code, expose it.
246+
for prov in alloc.provenance().get_range(this, overlap.into()) {
247+
this.expose_provenance(prov)?;
253248
}
254249
}
255250
AccessEvent::Write(_, certain) => {

tests/fail/function_calls/arg_inplace_locals_alias.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Ensure we detect aliasing of two in-place arguments for the tricky case where they do not
2+
//! live in memory.
13
//@revisions: stack tree
24
//@[tree]compile-flags: -Zmiri-tree-borrows
35
// Validation forces more things into memory, which we can't have here.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//! Ensure we detect aliasing of a in-place argument with the return place for the tricky case where
2+
//! they do not live in memory.
3+
//@revisions: stack tree
4+
//@[tree]compile-flags: -Zmiri-tree-borrows
5+
// Validation forces more things into memory, which we can't have here.
6+
//@compile-flags: -Zmiri-disable-validation
7+
#![feature(custom_mir, core_intrinsics)]
8+
use std::intrinsics::mir::*;
9+
10+
#[allow(unused)]
11+
pub struct S(i32);
12+
13+
#[custom_mir(dialect = "runtime", phase = "optimized")]
14+
fn main() {
15+
mir! {
16+
let _unit: ();
17+
{
18+
let staging = S(42); // This forces `staging` into memory...
19+
let _non_copy = staging; // ... so we move it to a non-inmemory local here.
20+
// This specifically uses a type with scalar representation to tempt Miri to use the
21+
// efficient way of storing local variables (outside adressable memory).
22+
Call(_non_copy = callee(Move(_non_copy)), ReturnTo(after_call), UnwindContinue())
23+
//~[stack]^ ERROR: not granting access
24+
//~[tree]| ERROR: /reborrow .* forbidden/
25+
}
26+
after_call = {
27+
Return()
28+
}
29+
}
30+
}
31+
32+
pub fn callee(x: S) -> S {
33+
x
34+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error: Undefined Behavior: not granting access to tag <TAG> because that would remove [Unique for <TAG>] which is strongly protected
2+
--> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC
3+
|
4+
LL | Call(_non_copy = callee(Move(_non_copy)), ReturnTo(after_call), UnwindContinue())
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
6+
|
7+
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
8+
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
9+
help: <TAG> was created here, as the root tag for ALLOC
10+
--> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC
11+
|
12+
LL | Call(_non_copy = callee(Move(_non_copy)), ReturnTo(after_call), UnwindContinue())
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
help: <TAG> is this argument
15+
--> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC
16+
|
17+
LL | x
18+
| ^
19+
= note: BACKTRACE (of the first span):
20+
= note: inside `main` at tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC
21+
22+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
23+
24+
error: aborting due to 1 previous error
25+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
error: Undefined Behavior: reborrow through <TAG> (root of the allocation) at ALLOC[0x0] is forbidden
2+
--> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC
3+
|
4+
LL | Call(_non_copy = callee(Move(_non_copy)), ReturnTo(after_call), UnwindContinue())
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
6+
|
7+
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
8+
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/tree-borrows.md for further information
9+
= help: the accessed tag <TAG> (root of the allocation) is foreign to the protected tag <TAG> (i.e., it is not a child)
10+
= help: this reborrow (acting as a foreign read access) would cause the protected tag <TAG> (currently Active) to become Disabled
11+
= help: protected tags must never be Disabled
12+
help: the accessed tag <TAG> was created here
13+
--> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC
14+
|
15+
LL | Call(_non_copy = callee(Move(_non_copy)), ReturnTo(after_call), UnwindContinue())
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
help: the protected tag <TAG> was created here, in the initial state Reserved
18+
--> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC
19+
|
20+
LL | x
21+
| ^
22+
help: the protected tag <TAG> later transitioned to Active due to a child write access at offsets [0x0..0x4]
23+
--> tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC
24+
|
25+
LL | x
26+
| ^
27+
= help: this transition corresponds to the first write to a 2-phase borrowed mutable reference
28+
= note: BACKTRACE (of the first span):
29+
= note: inside `main` at tests/fail/function_calls/arg_inplace_locals_alias_ret.rs:LL:CC
30+
31+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
32+
33+
error: aborting due to 1 previous error
34+

0 commit comments

Comments
 (0)