Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0ed3ef4
Use GH app for authenticating pull PRs
Kobzol Jul 29, 2025
1fd183e
Apply suggestions from code review
Kobzol Jul 29, 2025
6508b5a
Merge pull request #4505 from Kobzol/ci-gh-app
RalfJung Jul 29, 2025
64ed2b5
rustup
RalfJung Jul 31, 2025
76a213b
rely on preinstalled rustup on windows-arm
RalfJung Jul 31, 2025
4768724
Merge pull request #4509 from RalfJung/win-ci
RalfJung Jul 31, 2025
431fc2a
bless cargo miri doctest execution
RalfJung Jul 31, 2025
63cbeff
Merge pull request #4508 from RalfJung/rustup
RalfJung Jul 31, 2025
67cce09
Prepare for merging from rust-lang/rust
Aug 1, 2025
aa73f45
Merge ref 'adcb3d3b4cd3' from rust-lang/rust
Aug 1, 2025
620141d
fmt
Aug 1, 2025
be358c6
Merge pull request #4510 from rust-lang/rustup-2025-08-01
RalfJung Aug 1, 2025
6ab38e4
update rustup PR message
RalfJung Aug 1, 2025
8bd9bb9
Merge pull request #4511 from RalfJung/auto-rustup
RalfJung Aug 1, 2025
ff400ea
Prepare for merging from rust-lang/rust
Aug 4, 2025
4c07ca6
Merge ref '07b7dc90ee4d' from rust-lang/rust
Aug 4, 2025
fed28f8
Merge pull request #4513 from rust-lang/rustup-2025-08-04
saethlin Aug 4, 2025
55a8c2d
Prepare for merging from rust-lang/rust
Aug 9, 2025
fd45eef
Merge ref '4c7749e8c8e5' from rust-lang/rust
Aug 9, 2025
b4e279e
Remove cfg(bootstrap) for strict_overflow_ops
saethlin Aug 9, 2025
547e2b7
Fix a clippy::needless_borrow
saethlin Aug 9, 2025
5a79c57
Add gettid support for Android
saethlin Aug 10, 2025
210bd5f
Merge pull request #4518 from rust-lang/rustup-2025-08-09
saethlin Aug 10, 2025
117a095
Add tracing to data race functions
Stypox Aug 11, 2025
0b78f63
Prepare for merging from rust-lang/rust
Aug 13, 2025
24eaf5d
Merge ref '1553adfe6884' from rust-lang/rust
Aug 13, 2025
542bd3e
Merge pull request #4525 from rust-lang/rustup-2025-08-13
saethlin Aug 13, 2025
3ff426b
Prepare for merging from rust-lang/rust
Aug 15, 2025
c549eb3
Merge ref '3507a749b365' from rust-lang/rust
Aug 15, 2025
216b606
Merge pull request #4527 from rust-lang/rustup-2025-08-15
oli-obk Aug 15, 2025
122517d
Prepare for merging from rust-lang/rust
Aug 18, 2025
9cac742
Merge ref '425a9c0a0e36' from rust-lang/rust
Aug 18, 2025
244eea5
fmt
Aug 18, 2025
4f1de56
Merge pull request #4528 from rust-lang/rustup-2025-08-18
RalfJung Aug 18, 2025
3bb9172
Merge pull request #4523 from Stypox/data-race-tracing
RalfJung Aug 18, 2025
1c42add
triagebot: Show range-diff links on force pushes
RalfJung Aug 18, 2025
ebb5f98
Merge pull request #4529 from RalfJung/triagebot-range-diff-awesomeness
RalfJung Aug 18, 2025
ce2d0d1
link to TB doc in unsafe-code-guidelines
JoJoDeveloping Aug 19, 2025
a7bf08f
God bless the tests
JoJoDeveloping Aug 19, 2025
ed1ff8d
Merge pull request #4530 from JoJoDeveloping/tb-doc-ugc-link
RalfJung Aug 19, 2025
309b87f
Support weak definitions
bjorn3 Jun 26, 2025
f9d08d9
Merge pull request #4414 from bjorn3/weak_defs
RalfJung Aug 19, 2025
045b208
add back cfg(bootstrap), it is still needed
RalfJung Aug 20, 2025
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
18 changes: 9 additions & 9 deletions src/tools/miri/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ jobs:
sudo apt update
# Install needed packages
sudo apt install $(echo "libatomic1: zlib1g-dev:" | sed 's/:/:${{ matrix.multiarch }}/g')
- name: Install rustup on Windows ARM
if: ${{ matrix.os == 'windows-11-arm' }}
run: |
curl -LOs https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe
./rustup-init.exe -y --no-modify-path
echo "$USERPROFILE/.cargo/bin" >> "$GITHUB_PATH"
- uses: ./.github/workflows/setup
with:
toolchain_flags: "--host ${{ matrix.host_target }}"
Expand Down Expand Up @@ -169,7 +163,13 @@ jobs:
run: rustup toolchain install nightly --profile minimal
- name: Install rustup-toolchain-install-master
run: cargo install -f rustup-toolchain-install-master
- name: Push changes to a branch and create PR
# Create a token for the next step so it can create a PR that actually runs CI.
- uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ vars.APP_CLIENT_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: pull changes from rustc and create PR
run: |
# Make it easier to see what happens.
set -x
Expand Down Expand Up @@ -198,9 +198,9 @@ jobs:
BRANCH="rustup-$(date -u +%Y-%m-%d)"
git switch -c $BRANCH
git push -u origin $BRANCH
gh pr create -B master --title 'Automatic Rustup' --body 'Please close and re-open this PR to trigger CI, then enable auto-merge.'
gh pr create -B master --title 'Automatic Rustup' --body "Update \`rustc\` to https://github.com/rust-lang/rust/commit/$(cat rust-version)."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

cron-fail-notify:
name: cronjob failure notification
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 @@
733dab558992d902d6d17576de1da768094e2cf3
425a9c0a0e365c0b8c6cfd00c2ded83a73bed9a0
3 changes: 2 additions & 1 deletion src/tools/miri/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ pub fn report_error<'tcx>(
},
TreeBorrowsUb { title: _, details, history } => {
let mut helps = vec![
note!("this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental")
note!("this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental"),
note!("see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/tree-borrows.md for further information"),
];
for m in details {
helps.push(note!("{m}"));
Expand Down
8 changes: 7 additions & 1 deletion src/tools/miri/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use rustc_abi::{Align, ExternAbi, Size};
use rustc_apfloat::{Float, FloatConvert};
use rustc_hir::attrs::InlineAttr;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
#[allow(unused)]
use rustc_data_structures::static_assert_size;
use rustc_hir::attrs::InlineAttr;
use rustc_middle::mir;
use rustc_middle::query::TyCtxtAt;
use rustc_middle::ty::layout::{
Expand Down Expand Up @@ -1394,6 +1394,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
GlobalDataRaceHandler::Genmc(genmc_ctx) =>
genmc_ctx.memory_load(machine, ptr.addr(), range.size)?,
GlobalDataRaceHandler::Vclocks(_data_race) => {
let _trace = enter_trace_span!(data_race::before_memory_read);
let AllocDataRaceHandler::Vclocks(data_race, weak_memory) = &alloc_extra.data_race
else {
unreachable!();
Expand Down Expand Up @@ -1429,6 +1430,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
genmc_ctx.memory_store(machine, ptr.addr(), range.size)?;
}
GlobalDataRaceHandler::Vclocks(_global_state) => {
let _trace = enter_trace_span!(data_race::before_memory_write);
let AllocDataRaceHandler::Vclocks(data_race, weak_memory) =
&mut alloc_extra.data_race
else {
Expand Down Expand Up @@ -1465,6 +1467,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
GlobalDataRaceHandler::Genmc(genmc_ctx) =>
genmc_ctx.handle_dealloc(machine, ptr.addr(), size, align, kind)?,
GlobalDataRaceHandler::Vclocks(_global_state) => {
let _trace = enter_trace_span!(data_race::before_memory_deallocation);
let data_race = alloc_extra.data_race.as_vclocks_mut().unwrap();
data_race.write(
alloc_id,
Expand Down Expand Up @@ -1675,6 +1678,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
local: mir::Local,
) -> InterpResult<'tcx> {
if let Some(data_race) = &frame.extra.data_race {
let _trace = enter_trace_span!(data_race::after_local_read);
data_race.local_read(local, &ecx.machine);
}
interp_ok(())
Expand All @@ -1686,6 +1690,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
storage_live: bool,
) -> InterpResult<'tcx> {
if let Some(data_race) = &ecx.frame().extra.data_race {
let _trace = enter_trace_span!(data_race::after_local_write);
data_race.local_write(local, storage_live, &ecx.machine);
}
interp_ok(())
Expand All @@ -1708,6 +1713,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
if let Some(data_race) =
&machine.threads.active_thread_stack().last().unwrap().extra.data_race
{
let _trace = enter_trace_span!(data_race::after_local_moved_to_memory);
data_race.local_moved_to_memory(
local,
alloc_info.data_race.as_vclocks_mut().unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let ptr = left.to_scalar().to_pointer(this)?;
// We do the actual operation with usize-typed scalars.
let left = ImmTy::from_uint(ptr.addr().bytes(), this.machine.layouts.usize);
let result = this.binary_op(bin_op, &left, &right)?;
let result = this.binary_op(bin_op, &left, right)?;
// Construct a new pointer with the provenance of `ptr` (the LHS).
let result_ptr = Pointer::new(
ptr.provenance,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/src/shims/extern_static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<'tcx> MiriMachine<'tcx> {
}
"android" => {
Self::null_ptr_extern_statics(ecx, &["bsd_signal"])?;
Self::weak_symbol_extern_statics(ecx, &["signal", "getrandom"])?;
Self::weak_symbol_extern_statics(ecx, &["signal", "getrandom", "gettid"])?;
}
"windows" => {
// "_tls_used"
Expand Down
103 changes: 75 additions & 28 deletions src/tools/miri/src/shims/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::path::Path;
use rustc_abi::{Align, AlignFromBytesError, CanonAbi, Size};
use rustc_apfloat::Float;
use rustc_ast::expand::allocator::alloc_error_handler_name;
use rustc_hir::attrs::Linkage;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::CrateNum;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
Expand Down Expand Up @@ -138,7 +139,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
Entry::Occupied(e) => e.into_mut(),
Entry::Vacant(e) => {
// Find it if it was not cached.
let mut instance_and_crate: Option<(ty::Instance<'_>, CrateNum)> = None;

struct SymbolTarget<'tcx> {
instance: ty::Instance<'tcx>,
cnum: CrateNum,
is_weak: bool,
}
let mut symbol_target: Option<SymbolTarget<'tcx>> = None;
helpers::iter_exported_symbols(tcx, |cnum, def_id| {
let attrs = tcx.codegen_fn_attrs(def_id);
// Skip over imports of items.
Expand All @@ -155,40 +162,80 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {

let instance = Instance::mono(tcx, def_id);
let symbol_name = tcx.symbol_name(instance).name;
let is_weak = attrs.linkage == Some(Linkage::WeakAny);
if symbol_name == link_name.as_str() {
if let Some((original_instance, original_cnum)) = instance_and_crate {
// Make sure we are consistent wrt what is 'first' and 'second'.
let original_span = tcx.def_span(original_instance.def_id()).data();
let span = tcx.def_span(def_id).data();
if original_span < span {
throw_machine_stop!(TerminationInfo::MultipleSymbolDefinitions {
link_name,
first: original_span,
first_crate: tcx.crate_name(original_cnum),
second: span,
second_crate: tcx.crate_name(cnum),
});
} else {
throw_machine_stop!(TerminationInfo::MultipleSymbolDefinitions {
link_name,
first: span,
first_crate: tcx.crate_name(cnum),
second: original_span,
second_crate: tcx.crate_name(original_cnum),
});
if let Some(original) = &symbol_target {
// There is more than one definition with this name. What we do now
// depends on whether one or both definitions are weak.
match (is_weak, original.is_weak) {
(false, true) => {
// Original definition is a weak definition. Override it.

symbol_target = Some(SymbolTarget {
instance: ty::Instance::mono(tcx, def_id),
cnum,
is_weak,
});
}
(true, false) => {
// Current definition is a weak definition. Keep the original one.
}
(true, true) | (false, false) => {
// Either both definitions are non-weak or both are weak. In
// either case return an error. For weak definitions we error
// because it is unspecified which definition would have been
// picked by the linker.

// Make sure we are consistent wrt what is 'first' and 'second'.
let original_span =
tcx.def_span(original.instance.def_id()).data();
let span = tcx.def_span(def_id).data();
if original_span < span {
throw_machine_stop!(
TerminationInfo::MultipleSymbolDefinitions {
link_name,
first: original_span,
first_crate: tcx.crate_name(original.cnum),
second: span,
second_crate: tcx.crate_name(cnum),
}
);
} else {
throw_machine_stop!(
TerminationInfo::MultipleSymbolDefinitions {
link_name,
first: span,
first_crate: tcx.crate_name(cnum),
second: original_span,
second_crate: tcx.crate_name(original.cnum),
}
);
}
}
}
} else {
symbol_target = Some(SymbolTarget {
instance: ty::Instance::mono(tcx, def_id),
cnum,
is_weak,
});
}
if !matches!(tcx.def_kind(def_id), DefKind::Fn | DefKind::AssocFn) {
throw_ub_format!(
"attempt to call an exported symbol that is not defined as a function"
);
}
instance_and_crate = Some((ty::Instance::mono(tcx, def_id), cnum));
}
interp_ok(())
})?;

e.insert(instance_and_crate.map(|ic| ic.0))
// Once we identified the instance corresponding to the symbol, ensure
// it is a function. It is okay to encounter non-functions in the search above
// as long as the final instance we arrive at is a function.
if let Some(SymbolTarget { instance, .. }) = symbol_target {
if !matches!(tcx.def_kind(instance.def_id()), DefKind::Fn | DefKind::AssocFn) {
throw_ub_format!(
"attempt to call an exported symbol that is not defined as a function"
);
}
}

e.insert(symbol_target.map(|SymbolTarget { instance, .. }| instance))
}
};
match instance {
Expand Down
3 changes: 2 additions & 1 deletion src/tools/miri/src/shims/native_lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
let p_map = alloc.provenance();
for idx in overlap {
// If a provenance was read by the foreign code, expose it.
if let Some((prov, _idx)) = p_map.get_byte(Size::from_bytes(idx), this) {
if let Some((prov, _idx)) = p_map.get_byte(Size::from_bytes(idx), this)
{
this.expose_provenance(prov)?;
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/tools/miri/src/shims/unix/android/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ use rustc_span::Symbol;
use rustc_target::callconv::FnAbi;

use crate::shims::unix::android::thread::prctl;
use crate::shims::unix::env::EvalContextExt as _;
use crate::shims::unix::linux_like::epoll::EvalContextExt as _;
use crate::shims::unix::linux_like::eventfd::EvalContextExt as _;
use crate::shims::unix::linux_like::syscall::syscall;
use crate::*;

pub fn is_dyn_sym(_name: &str) -> bool {
false
pub fn is_dyn_sym(name: &str) -> bool {
matches!(name, "gettid")
}

impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
Expand Down Expand Up @@ -54,6 +55,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?;
}

"gettid" => {
let [] = this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?;
let result = this.unix_gettid(link_name.as_str())?;
this.write_scalar(result, dest)?;
}

// Dynamically invoked syscalls
"syscall" => syscall(this, link_name, abi, args, dest)?,

Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/test-cargo-miri/run-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def cargo_miri(cmd, quiet = True, targets = None):

def normalize_stdout(str):
str = str.replace("src\\", "src/") # normalize paths across platforms
str = re.sub("finished in \\d+\\.\\d\\ds", "finished in $TIME", str) # the time keeps changing, obviously
str = re.sub("\\b\\d+\\.\\d+s\\b", "$TIME", str) # the time keeps changing, obviously
return str

def check_output(actual, path, name):
Expand Down
1 change: 1 addition & 0 deletions src/tools/miri/test-cargo-miri/test.default.stdout.ref
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ running 5 tests
.....
test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

all doctests ran in $TIME; merged doctests compilation took $TIME
1 change: 1 addition & 0 deletions src/tools/miri/test-cargo-miri/test.filter.stdout.ref
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out; finished in $TIME

all doctests ran in $TIME; merged doctests compilation took $TIME
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ running 5 tests
.....
test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

all doctests ran in $TIME; merged doctests compilation took $TIME

running 5 tests
.....
test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

all doctests ran in $TIME; merged doctests compilation took $TIME
1 change: 1 addition & 0 deletions src/tools/miri/tests/fail/async-shared-mutable.tree.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | *x = 1;
| ^^^^^^ Undefined Behavior occurred here
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/tree-borrows.md for further information
= help: the accessed tag <TAG> has state Frozen which forbids this child write access
help: the accessed tag <TAG> was created here, in the initial state Reserved
--> tests/fail/async-shared-mutable.rs:LL:CC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | let _val = *target_alias;
| ^^^^^^^^^^^^^ Undefined Behavior occurred here
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/tree-borrows.md for further information
= help: the accessed tag <TAG> has state Disabled which forbids this child read access
help: the accessed tag <TAG> was created here, in the initial state Frozen
--> tests/fail/both_borrows/alias_through_mutation.rs:LL:CC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | *x = 1;
| ^^^^^^ Undefined Behavior occurred here
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/tree-borrows.md for further information
= help: the accessed tag <TAG> has state Reserved (conflicted) which forbids this child write access
help: the accessed tag <TAG> was created here, in the initial state Reserved
--> tests/fail/both_borrows/aliasing_mut1.rs:LL:CC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LL | *y = 2;
| ^^^^^^ Undefined Behavior occurred here
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/tree-borrows.md for further information
= help: the accessed tag <TAG> has state Reserved (conflicted) which forbids this child write access
help: the accessed tag <TAG> was created here, in the initial state Reserved
--> tests/fail/both_borrows/aliasing_mut2.rs:LL:CC
Expand Down
Loading
Loading