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

Rollup of 6 pull requests #122953

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
d3299af
transmute: caution against int2ptr transmutation
RalfJung Mar 12, 2024
96674fc
Preparing for merge from rustc
Mar 17, 2024
0dff16a
Merge from rustc
Mar 17, 2024
caa57dd
Auto merge of #3384 - rust-lang:rustup-2024-03-17, r=RalfJung
bors Mar 17, 2024
b4cb2ee
fix Zulip topic for PR-creation message
RalfJung Mar 17, 2024
dd5b4f5
Auto merge of #3386 - RalfJung:ci, r=RalfJung
bors Mar 17, 2024
a6f362f
make 'invalidate' benchmark shorter
RalfJung Mar 17, 2024
c99c314
add exposed-provenance example where we miss UB
RalfJung Mar 18, 2024
d7864d2
Auto merge of #3388 - RalfJung:exposed, r=RalfJung
bors Mar 18, 2024
311024c
rename 'invalidate' bench to something more clear
RalfJung Mar 18, 2024
b648a9a
Auto merge of #3387 - RalfJung:bench, r=RalfJung
bors Mar 18, 2024
74b68af
Preparing for merge from rustc
Mar 19, 2024
be6c170
Merge from rustc
Mar 19, 2024
bca5e2c
Auto merge of #3390 - rust-lang:rustup-2024-03-19, r=oli-obk
bors Mar 19, 2024
f4adb1e
add notes on how to store 'ptr or int'
RalfJung Mar 14, 2024
92a841d
remove duplicate test
RalfJung Mar 19, 2024
67966f3
Auto merge of #3391 - RalfJung:dedup, r=RalfJung
bors Mar 19, 2024
e539804
run full mono-item collection on all MIRI_BE_RUSTC=target builds
RalfJung Mar 19, 2024
6bcd9bc
Auto merge of #3392 - RalfJung:post-mono, r=oli-obk
bors Mar 20, 2024
89bc81f
Allow `llvm.x86.sse2.pause` instrinsic to be called without SSE2
eduardosm Mar 21, 2024
f61f45f
Auto merge of #3393 - eduardosm:x86-pause-without-sse2, r=RalfJung
bors Mar 21, 2024
5719d09
Preparing for merge from rustc
RalfJung Mar 22, 2024
ee57d2b
Merge from rustc
RalfJung Mar 22, 2024
2fae357
Auto merge of #3394 - RalfJung:rustup, r=RalfJung
bors Mar 22, 2024
063f011
add test for #52334
matthiaskrgr Mar 22, 2024
c3bde24
add test for #64784 Declarative macros can create infinite glob impo…
matthiaskrgr Mar 22, 2024
72d2b59
add test for str as extern "C" arg causes compiler panic #80125
matthiaskrgr Mar 22, 2024
6b0dfc5
add test for ice 83056 "bad input type for cast"
matthiaskrgr Mar 22, 2024
c7ef3cd
add test for #88212 ICE when lambda captures unsized local
matthiaskrgr Mar 22, 2024
3c1db06
add test for 88421 ICE: could not fully normalize `&<MyType as std::o…
matthiaskrgr Mar 22, 2024
efc57fb
add test for ice #90691 ICE: resolution failed during building vtable…
matthiaskrgr Mar 22, 2024
15ef7a0
add test for stack overflow with recursive type #98842
matthiaskrgr Mar 22, 2024
1fcf2ea
Uniquify ReError on input mode in canonicalizer
compiler-errors Mar 22, 2024
0115f73
Preparing for merge from rustc
Mar 23, 2024
89b9b67
Merge from rustc
Mar 23, 2024
5039f8b
fmt
Mar 23, 2024
f0d864f
Auto merge of #3395 - rust-lang:rustup-2024-03-23, r=saethlin
bors Mar 23, 2024
d7eeb71
add issue numbers via // issue: rust-lang/rust#ISSUE_NUM directive
matthiaskrgr Mar 22, 2024
c87ec61
add support for missing SIMD float intrinsics
RalfJung Mar 23, 2024
e19cc5e
Auto merge of #3396 - RalfJung:simd-float, r=RalfJung
bors Mar 23, 2024
12e3629
add test for #99945
matthiaskrgr Mar 23, 2024
2f9a240
add test for opaque type with non-universal region substs #101852
matthiaskrgr Mar 23, 2024
e54bff7
add test for #104779 opaque types, patterns and subtyping ICE: Index…
matthiaskrgr Mar 23, 2024
f1f287f
add test for ICE "raw ptr comparison should already be caught in the…
matthiaskrgr Mar 23, 2024
f8aeac8
add test for #106423
matthiaskrgr Mar 23, 2024
cc422ce
add test for ICE #106444
matthiaskrgr Mar 23, 2024
f2bc9c5
add test for #106874 ICE BoundUniversalRegionError
matthiaskrgr Mar 23, 2024
368bfb2
add test for #107228
matthiaskrgr Mar 23, 2024
2d610f7
Report retags as distinct from real memory accesses for data races
Zoxc Mar 17, 2024
9aea37d
address review feedback
matthiaskrgr Mar 23, 2024
246f746
Add test in `higher-ranked`
Luv-Ray Mar 23, 2024
59b2945
Auto merge of #3385 - Zoxc:read-types, r=RalfJung
bors Mar 23, 2024
4e721c0
Rollup merge of #122379 - RalfJung:int2ptr-transmute, r=m-ou-se
matthiaskrgr Mar 23, 2024
6b4f9c9
Rollup merge of #122895 - matthiaskrgr:ice-tests-5xxxx-to-9xxxx, r=fm…
matthiaskrgr Mar 23, 2024
2e57c77
Rollup merge of #122907 - compiler-errors:uniquify-reerror, r=lcnr
matthiaskrgr Mar 23, 2024
d1bb4cd
Rollup merge of #122942 - Luv-Ray:master, r=lcnr
matthiaskrgr Mar 23, 2024
bad56c4
Rollup merge of #122943 - matthiaskrgr:ice-tests-9xxxx-to-12xxxx, r=f…
matthiaskrgr Mar 23, 2024
70b2185
Rollup merge of #122952 - RalfJung:miri, r=RalfJung
matthiaskrgr Mar 23, 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
3 changes: 1 addition & 2 deletions compiler/rustc_next_trait_solver/src/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeFolder<I>
// FIXME: We should investigate the perf implications of not uniquifying
// `ReErased`. We may be able to short-circuit registering region
// obligations if we encounter a `ReErased` on one side, for example.
ty::ReStatic | ty::ReErased => match self.canonicalize_mode {
ty::ReStatic | ty::ReErased | ty::ReError(_) => match self.canonicalize_mode {
CanonicalizeMode::Input => CanonicalVarKind::Region(ty::UniverseIndex::ROOT),
CanonicalizeMode::Response { .. } => return r,
},
Expand Down Expand Up @@ -277,7 +277,6 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeFolder<I>
}
}
}
ty::ReError(_) => return r,
};

let existing_bound_var = match self.canonicalize_mode {
Expand Down
41 changes: 33 additions & 8 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,14 +1164,6 @@ extern "rust-intrinsic" {
/// may lead to unexpected and unstable compilation results. This makes `transmute` **incredibly
/// unsafe**. `transmute` should be the absolute last resort.
///
/// Transmuting pointers *to* integers in a `const` context is [undefined behavior][ub],
/// unless the pointer was originally created *from* an integer.
/// (That includes this function specifically, integer-to-pointer casts, and helpers like [`invalid`][crate::ptr::dangling],
/// but also semantically-equivalent conversions such as punning through `repr(C)` union fields.)
/// Any attempt to use the resulting value for integer operations will abort const-evaluation.
/// (And even outside `const`, such transmutation is touching on many unspecified aspects of the
/// Rust memory model and should be avoided. See below for alternatives.)
///
/// Because `transmute` is a by-value operation, alignment of the *transmuted values
/// themselves* is not a concern. As with any other function, the compiler already ensures
/// both `Src` and `Dst` are properly aligned. However, when transmuting values that *point
Expand All @@ -1182,6 +1174,39 @@ extern "rust-intrinsic" {
///
/// [ub]: ../../reference/behavior-considered-undefined.html
///
/// # Transmutation between pointers and integers
///
/// Special care has to be taken when transmuting between pointers and integers, e.g.
/// transmuting between `*const ()` and `usize`.
///
/// Transmuting *pointers to integers* in a `const` context is [undefined behavior][ub], unless
/// the pointer was originally created *from* an integer. (That includes this function
/// specifically, integer-to-pointer casts, and helpers like [`dangling`][crate::ptr::dangling],
/// but also semantically-equivalent conversions such as punning through `repr(C)` union
/// fields.) Any attempt to use the resulting value for integer operations will abort
/// const-evaluation. (And even outside `const`, such transmutation is touching on many
/// unspecified aspects of the Rust memory model and should be avoided. See below for
/// alternatives.)
///
/// Transmuting *integers to pointers* is a largely unspecified operation. It is likely *not*
/// equivalent to an `as` cast. Doing non-zero-sized memory accesses with a pointer constructed
/// this way is currently considered undefined behavior.
///
/// All this also applies when the integer is nested inside an array, tuple, struct, or enum.
/// However, `MaybeUninit<usize>` is not considered an integer type for the purpose of this
/// section. Transmuting `*const ()` to `MaybeUninit<usize>` is fine---but then calling
/// `assume_init()` on that result is considered as completing the pointer-to-integer transmute
/// and thus runs into the issues discussed above.
///
/// In particular, doing a pointer-to-integer-to-pointer roundtrip via `transmute` is *not* a
/// lossless process. If you want to round-trip a pointer through an integer in a way that you
/// can get back the original pointer, you need to use `as` casts, or replace the integer type
/// by `MaybeUninit<$int>` (and never call `assume_init()`). If you are looking for a way to
/// store data of arbitrary type, also use `MaybeUninit<T>` (that will also handle uninitialized
/// memory due to padding). If you specifically need to store something that is "either an
/// integer or a pointer", use `*mut ()`: integers can be converted to pointers and back without
/// any loss (via `as` casts or via `transmute`).
///
/// # Examples
///
/// There are a few things that `transmute` is really useful for.
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ jobs:
run: |
PR=$(gh pr create -B master --title 'Automatic Rustup' --body '')
~/.local/bin/zulip-send --user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com \
--stream miri --subject "Cron Job Failure (miri, $(date -u +%Y-%m))" \
--stream miri --subject "Miri Build Failure ($(date -u +%Y-%m))" \
--message "A PR doing a rustc-pull [has been automatically created]($PR) for your convenience."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
version = 3

[[package]]
name = "invalidate"
name = "range-iteration"
version = "0.1.0"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "invalidate"
name = "range-iteration"
version = "0.1.0"
edition = "2021"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! This generates a lot of work for the AllocId part of the GC.
fn main() {
// The end of the range is just chosen to make the benchmark run for a few seconds.
for _ in 0..200_000 {}
for _ in 0..50_000 {}
}
2 changes: 1 addition & 1 deletion src/tools/miri/rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ee03c286cfdca26fa5b2a4ee40957625d2c826ff
c3b05c6e5b5b59613350b8c2875b0add67ed74df
20 changes: 20 additions & 0 deletions src/tools/miri/src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,26 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
});
}
}

fn after_analysis<'tcx>(
&mut self,
_: &rustc_interface::interface::Compiler,
queries: &'tcx rustc_interface::Queries<'tcx>,
) -> Compilation {
queries.global_ctxt().unwrap().enter(|tcx| {
if self.target_crate {
// cargo-miri has patched the compiler flags to make these into check-only builds,
// but we are still emulating regular rustc builds, which would perform post-mono
// const-eval during collection. So let's also do that here, even if we might be
// running with `--emit=metadata`. In particular this is needed to make
// `compile_fail` doc tests trigger post-mono errors.
// In general `collect_and_partition_mono_items` is not safe to call in check-only
// builds, but we are setting `-Zalways-encode-mir` which avoids those issues.
let _ = tcx.collect_and_partition_mono_items(());
}
});
Compilation::Continue
}
}

fn show_error(msg: &impl std::fmt::Display) -> ! {
Expand Down
17 changes: 15 additions & 2 deletions src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::borrow_tracker::{
stacked_borrows::diagnostics::{AllocHistory, DiagnosticCx, DiagnosticCxBuilder},
GlobalStateInner, ProtectorKind,
};
use crate::concurrency::data_race::{NaReadType, NaWriteType};
use crate::*;

use diagnostics::{RetagCause, RetagInfo};
Expand Down Expand Up @@ -751,7 +752,13 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
assert_eq!(access, AccessKind::Write);
// Make sure the data race model also knows about this.
if let Some(data_race) = alloc_extra.data_race.as_mut() {
data_race.write(alloc_id, range, machine)?;
data_race.write(
alloc_id,
range,
NaWriteType::Retag,
Some(place.layout.ty),
machine,
)?;
}
}
}
Expand Down Expand Up @@ -794,7 +801,13 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
assert_eq!(access, AccessKind::Read);
// Make sure the data race model also knows about this.
if let Some(data_race) = alloc_extra.data_race.as_ref() {
data_race.read(alloc_id, range, &this.machine)?;
data_race.read(
alloc_id,
range,
NaReadType::Retag,
Some(place.layout.ty),
&this.machine,
)?;
}
}
Ok(())
Expand Down
13 changes: 11 additions & 2 deletions src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ use rustc_middle::{
use rustc_span::def_id::DefId;
use rustc_target::abi::{Abi, Size};

use crate::borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind};
use crate::*;
use crate::{
borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind},
concurrency::data_race::NaReadType,
};

pub mod diagnostics;
mod perms;
Expand Down Expand Up @@ -312,7 +315,13 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
// Also inform the data race model (but only if any bytes are actually affected).
if range.size.bytes() > 0 {
if let Some(data_race) = alloc_extra.data_race.as_ref() {
data_race.read(alloc_id, range, &this.machine)?;
data_race.read(
alloc_id,
range,
NaReadType::Retag,
Some(place.layout.ty),
&this.machine,
)?;
}
}

Expand Down
Loading
Loading