Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit abd406c

Browse files
committedDec 20, 2024·
Revert some miri changes
1 parent 0a56ec0 commit abd406c

28 files changed

+312
-351
lines changed
 

‎src/tools/miri/src/helpers.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
919919
if fn_abi.conv != exp_abi {
920920
throw_ub_format!(
921921
"calling a function with ABI {:?} using caller ABI {:?}",
922-
exp_abi, fn_abi.conv);
922+
exp_abi,
923+
fn_abi.conv
924+
);
923925
}
924926
interp_ok(())
925927
}
@@ -964,6 +966,21 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
964966
return interp_ok(());
965967
}
966968

969+
if ["__rust_alloc", "__rust_alloc_zeroed", "__rust_realloc", "__rust_dealloc"]
970+
.contains(&link_name.as_str())
971+
{
972+
let attrs = self.eval_context_ref().tcx.codegen_fn_attrs(instance.def_id());
973+
if attrs
974+
.linkage
975+
.map_or(false, |linkage| linkage == rustc_middle::mir::mono::Linkage::WeakAny)
976+
&& attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL)
977+
{
978+
// We intentionally intercept the allocator methods even though libstd provides
979+
// default implementations.
980+
return interp_ok(());
981+
}
982+
}
983+
967984
throw_machine_stop!(TerminationInfo::SymbolShimClashing {
968985
link_name,
969986
span: body.span.data(),

‎src/tools/miri/src/shims/alloc.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::iter;
22

33
use rustc_abi::{Align, Size};
4+
use rustc_ast::expand::allocator::AllocatorKind;
45

56
use crate::*;
67

@@ -51,6 +52,34 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5152
Align::from_bytes(prev_power_of_two(size)).unwrap()
5253
}
5354

55+
/// Emulates calling the internal __rust_* allocator functions
56+
fn emulate_allocator(
57+
&mut self,
58+
default: impl FnOnce(&mut MiriInterpCx<'tcx>) -> InterpResult<'tcx>,
59+
) -> InterpResult<'tcx, EmulateItemResult> {
60+
let this = self.eval_context_mut();
61+
62+
let Some(allocator_kind) = this.tcx.allocator_kind(()) else {
63+
// in real code, this symbol does not exist without an allocator
64+
return interp_ok(EmulateItemResult::NotSupported);
65+
};
66+
67+
match allocator_kind {
68+
AllocatorKind::Global => {
69+
// When `#[global_allocator]` is used, `__rust_*` is defined by the macro expansion
70+
// of this attribute. As such we have to call an exported Rust function,
71+
// and not execute any Miri shim. Somewhat unintuitively doing so is done
72+
// by returning `NotSupported`, which triggers the `lookup_exported_symbol`
73+
// fallback case in `emulate_foreign_item`.
74+
interp_ok(EmulateItemResult::NotSupported)
75+
}
76+
AllocatorKind::Default => {
77+
default(this)?;
78+
interp_ok(EmulateItemResult::NeedsReturn)
79+
}
80+
}
81+
}
82+
5483
fn malloc(&mut self, size: u64, zero_init: bool) -> InterpResult<'tcx, Pointer> {
5584
let this = self.eval_context_mut();
5685
let align = this.malloc_align(size);

‎src/tools/miri/src/shims/foreign_items.rs

Lines changed: 114 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::collections::hash_map::Entry;
22
use std::io::Write;
3+
use std::iter;
34
use std::path::Path;
45

56
use rustc_abi::{Align, AlignFromBytesError, Size};
@@ -501,33 +502,124 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
501502
}
502503

503504
// Rust allocation
504-
"miri_alloc" => {
505-
let [size, align] = this.check_shim(abi, Conv::Rust, link_name, args)?;
506-
let size = this.read_target_usize(size)?;
507-
let align = this.read_target_usize(align)?;
505+
"__rust_alloc" | "miri_alloc" => {
506+
let default = |ecx: &mut MiriInterpCx<'tcx>| {
507+
// Only call `check_shim` when `#[global_allocator]` isn't used. When that
508+
// macro is used, we act like no shim exists, so that the exported function can run.
509+
let [size, align] = ecx.check_shim(abi, Conv::Rust, link_name, args)?;
510+
let size = ecx.read_target_usize(size)?;
511+
let align = ecx.read_target_usize(align)?;
512+
513+
ecx.check_rustc_alloc_request(size, align)?;
514+
515+
let memory_kind = match link_name.as_str() {
516+
"__rust_alloc" => MiriMemoryKind::Rust,
517+
"miri_alloc" => MiriMemoryKind::Miri,
518+
_ => unreachable!(),
519+
};
508520

509-
this.check_rustc_alloc_request(size, align)?;
521+
let ptr = ecx.allocate_ptr(
522+
Size::from_bytes(size),
523+
Align::from_bytes(align).unwrap(),
524+
memory_kind.into(),
525+
)?;
510526

511-
let ptr = this.allocate_ptr(
512-
Size::from_bytes(size),
513-
Align::from_bytes(align).unwrap(),
514-
MiriMemoryKind::Miri.into(),
515-
)?;
527+
ecx.write_pointer(ptr, dest)
528+
};
516529

517-
this.write_pointer(ptr, dest)?;
530+
match link_name.as_str() {
531+
"__rust_alloc" => return this.emulate_allocator(default),
532+
"miri_alloc" => {
533+
default(this)?;
534+
return interp_ok(EmulateItemResult::NeedsReturn);
535+
}
536+
_ => unreachable!(),
537+
}
518538
}
519-
"miri_dealloc" => {
520-
let [ptr, old_size, align] = this.check_shim(abi, Conv::Rust, link_name, args)?;
521-
let ptr = this.read_pointer(ptr)?;
522-
let old_size = this.read_target_usize(old_size)?;
523-
let align = this.read_target_usize(align)?;
539+
"__rust_alloc_zeroed" => {
540+
return this.emulate_allocator(|this| {
541+
// See the comment for `__rust_alloc` why `check_shim` is only called in the
542+
// default case.
543+
let [size, align] = this.check_shim(abi, Conv::Rust, link_name, args)?;
544+
let size = this.read_target_usize(size)?;
545+
let align = this.read_target_usize(align)?;
524546

525-
// No need to check old_size/align; we anyway check that they match the allocation.
526-
this.deallocate_ptr(
527-
ptr,
528-
Some((Size::from_bytes(old_size), Align::from_bytes(align).unwrap())),
529-
MiriMemoryKind::Miri.into(),
530-
)?;
547+
this.check_rustc_alloc_request(size, align)?;
548+
549+
let ptr = this.allocate_ptr(
550+
Size::from_bytes(size),
551+
Align::from_bytes(align).unwrap(),
552+
MiriMemoryKind::Rust.into(),
553+
)?;
554+
555+
// We just allocated this, the access is definitely in-bounds.
556+
this.write_bytes_ptr(
557+
ptr.into(),
558+
iter::repeat(0u8).take(usize::try_from(size).unwrap()),
559+
)
560+
.unwrap();
561+
this.write_pointer(ptr, dest)
562+
});
563+
}
564+
"__rust_dealloc" | "miri_dealloc" => {
565+
let default = |ecx: &mut MiriInterpCx<'tcx>| {
566+
// See the comment for `__rust_alloc` why `check_shim` is only called in the
567+
// default case.
568+
let [ptr, old_size, align] =
569+
ecx.check_shim(abi, Conv::Rust, link_name, args)?;
570+
let ptr = ecx.read_pointer(ptr)?;
571+
let old_size = ecx.read_target_usize(old_size)?;
572+
let align = ecx.read_target_usize(align)?;
573+
574+
let memory_kind = match link_name.as_str() {
575+
"__rust_dealloc" => MiriMemoryKind::Rust,
576+
"miri_dealloc" => MiriMemoryKind::Miri,
577+
_ => unreachable!(),
578+
};
579+
580+
// No need to check old_size/align; we anyway check that they match the allocation.
581+
ecx.deallocate_ptr(
582+
ptr,
583+
Some((Size::from_bytes(old_size), Align::from_bytes(align).unwrap())),
584+
memory_kind.into(),
585+
)
586+
};
587+
588+
match link_name.as_str() {
589+
"__rust_dealloc" => {
590+
return this.emulate_allocator(default);
591+
}
592+
"miri_dealloc" => {
593+
default(this)?;
594+
return interp_ok(EmulateItemResult::NeedsReturn);
595+
}
596+
_ => unreachable!(),
597+
}
598+
}
599+
"__rust_realloc" => {
600+
return this.emulate_allocator(|this| {
601+
// See the comment for `__rust_alloc` why `check_shim` is only called in the
602+
// default case.
603+
let [ptr, old_size, align, new_size] =
604+
this.check_shim(abi, Conv::Rust, link_name, args)?;
605+
let ptr = this.read_pointer(ptr)?;
606+
let old_size = this.read_target_usize(old_size)?;
607+
let align = this.read_target_usize(align)?;
608+
let new_size = this.read_target_usize(new_size)?;
609+
// No need to check old_size; we anyway check that they match the allocation.
610+
611+
this.check_rustc_alloc_request(new_size, align)?;
612+
613+
let align = Align::from_bytes(align).unwrap();
614+
let new_ptr = this.reallocate_ptr(
615+
ptr,
616+
Some((Size::from_bytes(old_size), align)),
617+
Size::from_bytes(new_size),
618+
align,
619+
MiriMemoryKind::Rust.into(),
620+
)?;
621+
this.write_pointer(new_ptr, dest)
622+
});
531623
}
532624

533625
// C memory handling functions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN
2+
--> tests/fail/alloc/deallocate-bad-alignment.rs:LL:CC
3+
|
4+
LL | dealloc(x, Layout::from_size_align_unchecked(1, 2));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at tests/fail/alloc/deallocate-bad-alignment.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to 1 previous error
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
2+
--> tests/fail/alloc/deallocate-bad-size.rs:LL:CC
3+
|
4+
LL | dealloc(x, Layout::from_size_align_unchecked(2, 1));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at tests/fail/alloc/deallocate-bad-size.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to 1 previous error
15+

‎src/tools/miri/tests/fail/alloc/deallocate-twice.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: memory access failed: ALLOC has been freed, so this pointer is dangling
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
2+
--> tests/fail/alloc/deallocate-twice.rs:LL:CC
33
|
4-
LL | unsafe { libc::free(ptr as *mut libc::c_void) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
4+
LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
@@ -17,13 +17,7 @@ help: ALLOC was deallocated here:
1717
LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1919
= note: BACKTRACE (of the first span):
20-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
21-
= note: inside `std::alloc::__default_lib_allocator::__rust_dealloc` at RUSTLIB/std/src/alloc.rs:LL:CC
22-
note: inside `main`
23-
--> tests/fail/alloc/deallocate-twice.rs:LL:CC
24-
|
25-
LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
26-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
= note: inside `main` at tests/fail/alloc/deallocate-twice.rs:LL:CC
2721

2822
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2923

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: Undefined Behavior: deallocating ALLOC, which is Rust heap memory, using PLATFORM heap deallocation operation
2+
--> RUSTLIB/std/src/sys/alloc/PLATFORM.rs:LL:CC
3+
|
4+
LL | FREE();
5+
| ^ deallocating ALLOC, which is Rust heap memory, using PLATFORM heap deallocation operation
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `std::sys::alloc::PLATFORM::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at RUSTLIB/std/src/sys/alloc/PLATFORM.rs:LL:CC
11+
= note: inside `<std::alloc::System as std::alloc::Allocator>::deallocate` at RUSTLIB/std/src/alloc.rs:LL:CC
12+
note: inside `main`
13+
--> tests/fail/alloc/global_system_mixup.rs:LL:CC
14+
|
15+
LL | unsafe { System.deallocate(ptr, l) };
16+
| ^
17+
18+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
19+
20+
error: aborting due to 1 previous error
21+
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
error: memory leaked: ALLOC (C heap, size: 1, align: 1), allocated here:
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
1+
error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
2+
--> tests/fail/alloc/reallocate-bad-size.rs:LL:CC
33
|
4-
LL | unsafe { libc::realloc(ptr as *mut libc::c_void, new_size) as *mut u8 }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
66
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
79
= note: BACKTRACE:
8-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::realloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
9-
= note: inside `std::alloc::__default_lib_allocator::__rust_realloc` at RUSTLIB/std/src/alloc.rs:LL:CC
10-
note: inside `main`
11-
--> tests/fail/alloc/reallocate-bad-size.rs:LL:CC
12-
|
13-
LL | ... let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at tests/fail/alloc/reallocate-bad-size.rs:LL:CC
1511

1612
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1713

18-
note: set `MIRIFLAGS=-Zmiri-ignore-leaks` to disable this check
19-
2014
error: aborting due to 1 previous error
2115

‎src/tools/miri/tests/fail/alloc/reallocate-dangling.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: memory access failed: ALLOC has been freed, so this pointer is dangling
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
2+
--> tests/fail/alloc/reallocate-dangling.rs:LL:CC
33
|
4-
LL | unsafe { libc::realloc(ptr as *mut libc::c_void, new_size) as *mut u8 }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
4+
LL | let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
@@ -17,13 +17,7 @@ help: ALLOC was deallocated here:
1717
LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1919
= note: BACKTRACE (of the first span):
20-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::realloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
21-
= note: inside `std::alloc::__default_lib_allocator::__rust_realloc` at RUSTLIB/std/src/alloc.rs:LL:CC
22-
note: inside `main`
23-
--> tests/fail/alloc/reallocate-dangling.rs:LL:CC
24-
|
25-
LL | let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
26-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
= note: inside `main` at tests/fail/alloc/reallocate-dangling.rs:LL:CC
2721

2822
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2923

‎src/tools/miri/tests/fail/alloc/stack_free.stderr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
error: Undefined Behavior: deallocating ALLOC, which is stack variable memory, using C heap deallocation operation
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
1+
error: Undefined Behavior: deallocating ALLOC, which is stack variable memory, using Rust heap deallocation operation
2+
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
33
|
4-
LL | unsafe { libc::free(ptr as *mut libc::c_void) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating ALLOC, which is stack variable memory, using C heap deallocation operation
4+
LL | self.1.deallocate(From::from(ptr.cast()), layout);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating ALLOC, which is stack variable memory, using Rust heap deallocation operation
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: BACKTRACE:
10-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
11-
= note: inside `std::alloc::__default_lib_allocator::__rust_dealloc` at RUSTLIB/std/src/alloc.rs:LL:CC
1210
= note: inside `<std::boxed::Box<i32> as std::ops::Drop>::drop` at RUSTLIB/alloc/src/boxed.rs:LL:CC
1311
= note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
1412
= note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC

‎src/tools/miri/tests/fail/alloc/too_large.stderr

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
1-
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
2-
unsafe precondition(s) violated: Layout::from_size_align_unchecked requires that align is a power of 2 and the rounded-up allocation size does not exceed isize::MAX
3-
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4-
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
5-
thread caused non-unwinding panic. aborting.
6-
error: abnormal termination: the program aborted execution
7-
--> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
8-
|
9-
LL | unsafe { libc::abort() }
10-
| ^^^^^^^^^^^^^ the program aborted execution
11-
|
12-
= note: BACKTRACE:
13-
= note: inside `std::sys::pal::PLATFORM::abort_internal` at RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
14-
= note: inside `std::panicking::rust_panic_with_hook` at RUSTLIB/std/src/panicking.rs:LL:CC
15-
= note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
16-
= note: inside `std::sys::backtrace::__rust_end_short_backtrace::<{closure@std::panicking::begin_panic_handler::{closure#0}}, !>` at RUSTLIB/std/src/sys/backtrace.rs:LL:CC
17-
= note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC
18-
= note: inside `core::panicking::panic_nounwind` at RUSTLIB/core/src/panicking.rs:LL:CC
19-
= note: inside `std::alloc::Layout::from_size_align_unchecked::precondition_check` at RUSTLIB/core/src/ub_checks.rs:LL:CC
20-
= note: inside `std::alloc::Layout::from_size_align_unchecked` at RUSTLIB/core/src/ub_checks.rs:LL:CC
21-
= note: inside `std::alloc::__default_lib_allocator::__rust_alloc` at RUSTLIB/std/src/alloc.rs:LL:CC
22-
note: inside `main`
1+
error: Undefined Behavior: creating an allocation larger than half the address space
232
--> tests/fail/alloc/too_large.rs:LL:CC
243
|
254
LL | __rust_alloc(bytes, 1);
26-
| ^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^ creating an allocation larger than half the address space
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at tests/fail/alloc/too_large.rs:LL:CC
2711

2812
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2913

Lines changed: 10 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,14 @@
1-
thread 'rustc' panicked at src/tools/miri/src/shims/alloc.rs:LL:CC:
2-
called `Result::unwrap()` on an `Err` value: `1073741824` is too large
3-
stack backtrace:
4-
0: rust_begin_unwind
5-
at RUSTLIB/std/src/panicking.rs:LL:CC
6-
1: core::panicking::panic_fmt
7-
at RUSTLIB/core/src/panicking.rs:LL:CC
8-
2: core::result::unwrap_failed
9-
at RUSTLIB/core/src/result.rs:LL:CC
10-
3: <core::result::Result<rustc_abi::Align, rustc_abi::AlignFromBytesError>>::unwrap
11-
at RUSTLIB/core/src/result.rs:LL:CC
12-
4: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine> as miri::shims::alloc::EvalContextExt>::posix_memalign
13-
at ./src/shims/alloc.rs:LL:CC
14-
5: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine> as miri::shims::unix::foreign_items::EvalContextExt>::emulate_foreign_item_inner
15-
at ./src/shims/unix/foreign_items.rs:LL:CC
16-
6: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine> as miri::shims::foreign_items::EvalContextExtPriv>::emulate_foreign_item_inner
17-
at ./src/shims/foreign_items.rs:LL:CC
18-
7: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine> as miri::shims::foreign_items::EvalContextExt>::emulate_foreign_item
19-
at ./src/shims/foreign_items.rs:LL:CC
20-
8: <miri::machine::MiriMachine as rustc_const_eval::interpret::machine::Machine>::find_mir_or_eval_fn
21-
at ./src/machine.rs:LL:CC
22-
9: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine>>::init_fn_call
23-
at /home/gh-bjorn3/rust/compiler/rustc_const_eval/src/interpret/call.rs:LL:CC
24-
10: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine>>::eval_terminator
25-
at /home/gh-bjorn3/rust/compiler/rustc_const_eval/src/interpret/step.rs:LL:CC
26-
11: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine>>::step
27-
at /home/gh-bjorn3/rust/compiler/rustc_const_eval/src/interpret/step.rs:LL:CC
28-
12: <rustc_const_eval::interpret::eval_context::InterpCx<miri::machine::MiriMachine> as miri::concurrency::thread::EvalContextExt>::run_threads
29-
at ./src/concurrency/thread.rs:LL:CC
30-
13: miri::eval::eval_entry::{closure#0}
31-
at ./src/eval.rs:LL:CC
32-
14: <miri::eval::eval_entry::{closure#0} as core::ops::function::FnOnce<()>>::call_once
33-
at RUSTLIB/core/src/ops/function.rs:LL:CC
34-
15: <core::panic::unwind_safe::AssertUnwindSafe<miri::eval::eval_entry::{closure#0}> as core::ops::function::FnOnce<()>>::call_once
35-
at RUSTLIB/core/src/panic/unwind_safe.rs:LL:CC
36-
16: std::panicking::try::do_call
37-
at RUSTLIB/std/src/panicking.rs:LL:CC
38-
17: std::panicking::try
39-
at RUSTLIB/std/src/panicking.rs:LL:CC
40-
18: std::panic::catch_unwind
41-
at RUSTLIB/std/src/panic.rs:LL:CC
42-
19: miri::eval::eval_entry
43-
at ./src/eval.rs:LL:CC
44-
20: <miri::MiriCompilerCalls as rustc_driver_impl::Callbacks>::after_analysis
45-
at ./src/bin/miri.rs:LL:CC
46-
21: rustc_driver_impl::run_compiler::{closure#0}::{closure#2}
47-
at /home/gh-bjorn3/rust/compiler/rustc_driver_impl/src/lib.rs:LL:CC
48-
22: rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure#0}
49-
at /home/gh-bjorn3/rust/compiler/rustc_interface/src/passes.rs:LL:CC
50-
23: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt::{closure#3}
51-
at /home/gh-bjorn3/rust/compiler/rustc_middle/src/ty/context.rs:LL:CC
52-
24: rustc_middle::ty::context::tls::enter_context::{closure#0}
53-
at /home/gh-bjorn3/rust/compiler/rustc_middle/src/ty/context/tls.rs:LL:CC
54-
25: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::try_with
55-
at RUSTLIB/std/src/thread/local.rs:LL:CC
56-
26: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with
57-
at RUSTLIB/std/src/thread/local.rs:LL:CC
58-
27: rustc_middle::ty::context::tls::enter_context
59-
at /home/gh-bjorn3/rust/compiler/rustc_middle/src/ty/context/tls.rs:LL:CC
60-
28: <rustc_middle::ty::context::TyCtxt>::create_global_ctxt
61-
at /home/gh-bjorn3/rust/compiler/rustc_middle/src/ty/context.rs:LL:CC
62-
29: rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}
63-
at /home/gh-bjorn3/rust/compiler/rustc_interface/src/passes.rs:LL:CC
64-
30: <rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core::ops::function::FnOnce<(&rustc_interface::interface::Compiler, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
65-
at RUSTLIB/core/src/ops/function.rs:LL:CC
66-
31: <alloc::boxed::Box<dyn for<'a> core::ops::function::FnOnce<(&'a rustc_interface::interface::Compiler, &'a std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt<'a>>, &'a rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena<'a>>, &'a rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena<'a>>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}), Output = core::option::Option<rustc_interface::queries::Linker>>> as core::ops::function::FnOnce<(&rustc_interface::interface::Compiler, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once
67-
at RUSTLIB/alloc/src/boxed.rs:LL:CC
68-
32: rustc_interface::passes::create_and_enter_global_ctxt
69-
at /home/gh-bjorn3/rust/compiler/rustc_interface/src/passes.rs:LL:CC
70-
33: rustc_driver_impl::run_compiler::{closure#0}
71-
at /home/gh-bjorn3/rust/compiler/rustc_driver_impl/src/lib.rs:LL:CC
72-
34: rustc_interface::interface::run_compiler::{closure#1}::{closure#0}
73-
at /home/gh-bjorn3/rust/compiler/rustc_interface/src/interface.rs:LL:CC
74-
35: <core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once
75-
at RUSTLIB/core/src/panic/unwind_safe.rs:LL:CC
76-
36: std::panicking::try::do_call
77-
at RUSTLIB/std/src/panicking.rs:LL:CC
78-
37: std::panicking::try
79-
at RUSTLIB/std/src/panicking.rs:LL:CC
80-
38: std::panic::catch_unwind
81-
at RUSTLIB/std/src/panic.rs:LL:CC
82-
39: rustc_interface::interface::run_compiler::{closure#1}
83-
at /home/gh-bjorn3/rust/compiler/rustc_interface/src/interface.rs:LL:CC
84-
40: rustc_interface::util::run_in_thread_pool_with_globals::{closure#0}
85-
at /home/gh-bjorn3/rust/compiler/rustc_interface/src/util.rs:LL:CC
86-
41: rustc_interface::util::run_in_thread_with_globals::{closure#0}::{closure#0}::{closure#0}
87-
at /home/gh-bjorn3/rust/compiler/rustc_interface/src/util.rs:LL:CC
88-
42: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set
89-
at CARGO_REGISTRY/.../lib.rs:LL:CC
90-
43: rustc_span::create_session_globals_then
91-
at /home/gh-bjorn3/rust/compiler/rustc_span/src/lib.rs:LL:CC
92-
44: rustc_interface::util::run_in_thread_with_globals::{closure#0}::{closure#0}
93-
at /home/gh-bjorn3/rust/compiler/rustc_interface/src/util.rs:LL:CC
94-
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
95-
96-
error: the compiler unexpectedly panicked. this is a bug.
97-
98-
note: we would appreciate a bug report: https://github.com/rust-lang/miri/issues/new
99-
100-
note: please make sure that you have updated to the latest nightly
101-
102-
note: please attach the file at `/home/gh-bjorn3/rust/src/tools/miri/rustc-ice-2024-12-20T10_31_46-710436.txt` to your bug report
103-
104-
note: compiler flags: -Z ui-testing
105-
106-
query stack during panic:
107-
end of query stack
108-
109-
Miri caused an ICE during evaluation. Here's the interpreter backtrace at the time of the panic:
110-
note: the place in the program where the ICE was triggered
111-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
112-
|
113-
LL | let ret = unsafe { libc::posix_memalign(&mut out, align, layout.size()) };
114-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
115-
|
116-
= note: BACKTRACE:
117-
= note: inside `std::sys::alloc::unix::aligned_malloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
118-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::alloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
119-
= note: inside `std::alloc::__default_lib_allocator::__rust_alloc` at RUSTLIB/std/src/alloc.rs:LL:CC
120-
note: inside `main`
1+
error: unsupported operation: creating allocation with alignment ALIGN exceeding rustc's maximum supported value
1212
--> tests/fail/alloc/unsupported_big_alignment.rs:LL:CC
1223
|
1234
LL | __rust_alloc(1, 1 << 30);
124-
| ^^^^^^^^^^^^^^^^^^^^^^^^
125-
= note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at RUSTLIB/core/src/ops/function.rs:LL:CC
126-
= note: inside `std::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at RUSTLIB/std/src/sys/backtrace.rs:LL:CC
127-
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
128-
= note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at RUSTLIB/core/src/ops/function.rs:LL:CC
129-
= note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at RUSTLIB/std/src/panicking.rs:LL:CC
130-
= note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at RUSTLIB/std/src/panicking.rs:LL:CC
131-
= note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at RUSTLIB/std/src/panic.rs:LL:CC
132-
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
133-
= note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#1}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC
134-
= note: inside `std::panicking::r#try::<isize, {closure@std::rt::lang_start_internal::{closure#1}}>` at RUSTLIB/std/src/panicking.rs:LL:CC
135-
= note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#1}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC
136-
= note: inside `std::rt::lang_start_internal` at RUSTLIB/std/src/rt.rs:LL:CC
137-
= note: inside `std::rt::lang_start::<()>` at RUSTLIB/std/src/rt.rs:LL:CC
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^ creating allocation with alignment ALIGN exceeding rustc's maximum supported value
6+
|
7+
= help: this is likely not a bug in the program; it indicates that the program performed an operation that Miri does not support
8+
= note: BACKTRACE:
9+
= note: inside `main` at tests/fail/alloc/unsupported_big_alignment.rs:LL:CC
10+
11+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
12+
13+
error: aborting due to 1 previous error
13814

‎src/tools/miri/tests/fail/alloc/unsupported_non_power_two_alignment.stderr

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
1-
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
2-
unsafe precondition(s) violated: Layout::from_size_align_unchecked requires that align is a power of 2 and the rounded-up allocation size does not exceed isize::MAX
3-
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4-
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
5-
thread caused non-unwinding panic. aborting.
6-
error: abnormal termination: the program aborted execution
7-
--> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
8-
|
9-
LL | unsafe { libc::abort() }
10-
| ^^^^^^^^^^^^^ the program aborted execution
11-
|
12-
= note: BACKTRACE:
13-
= note: inside `std::sys::pal::PLATFORM::abort_internal` at RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
14-
= note: inside `std::panicking::rust_panic_with_hook` at RUSTLIB/std/src/panicking.rs:LL:CC
15-
= note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
16-
= note: inside `std::sys::backtrace::__rust_end_short_backtrace::<{closure@std::panicking::begin_panic_handler::{closure#0}}, !>` at RUSTLIB/std/src/sys/backtrace.rs:LL:CC
17-
= note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC
18-
= note: inside `core::panicking::panic_nounwind` at RUSTLIB/core/src/panicking.rs:LL:CC
19-
= note: inside `std::alloc::Layout::from_size_align_unchecked::precondition_check` at RUSTLIB/core/src/ub_checks.rs:LL:CC
20-
= note: inside `std::alloc::Layout::from_size_align_unchecked` at RUSTLIB/core/src/ub_checks.rs:LL:CC
21-
= note: inside `std::alloc::__default_lib_allocator::__rust_alloc` at RUSTLIB/std/src/alloc.rs:LL:CC
22-
note: inside `main`
1+
error: Undefined Behavior: creating allocation with non-power-of-two alignment ALIGN
232
--> tests/fail/alloc/unsupported_non_power_two_alignment.rs:LL:CC
243
|
254
LL | __rust_alloc(1, 3);
26-
| ^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^ creating allocation with non-power-of-two alignment ALIGN
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at tests/fail/alloc/unsupported_non_power_two_alignment.rs:LL:CC
2711

2812
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2913

‎src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.tree.stderr

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: deallocation through <TAG> at ALLOC[0x0] is forbidden
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
2+
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
33
|
4-
LL | unsafe { libc::free(ptr as *mut libc::c_void) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden
4+
LL | self.1.deallocate(From::from(ptr.cast()), layout);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden
66
|
77
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
88
= help: the accessed tag <TAG> is foreign to the protected tag <TAG> (i.e., it is not a child)
@@ -25,8 +25,6 @@ LL | || drop(Box::from_raw(ptr)),
2525
| ^^^^^^^^^^^^^^^^^^
2626
= help: this transition corresponds to a temporary loss of write permissions until function exit
2727
= note: BACKTRACE (of the first span):
28-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
29-
= note: inside `std::alloc::__default_lib_allocator::__rust_dealloc` at RUSTLIB/std/src/alloc.rs:LL:CC
3028
= note: inside `<std::boxed::Box<i32> as std::ops::Drop>::drop` at RUSTLIB/alloc/src/boxed.rs:LL:CC
3129
= note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
3230
= note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC

‎src/tools/miri/tests/fail/both_borrows/newtype_retagging.tree.stderr

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: deallocation through <TAG> at ALLOC[0x0] is forbidden
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
2+
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
33
|
4-
LL | unsafe { libc::free(ptr as *mut libc::c_void) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden
4+
LL | self.1.deallocate(From::from(ptr.cast()), layout);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden
66
|
77
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
88
= help: the accessed tag <TAG> is foreign to the protected tag <TAG> (i.e., it is not a child)
@@ -25,8 +25,6 @@ LL | || drop(Box::from_raw(ptr)),
2525
| ^^^^^^^^^^^^^^^^^^
2626
= help: this transition corresponds to a temporary loss of write permissions until function exit
2727
= note: BACKTRACE (of the first span):
28-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
29-
= note: inside `std::alloc::__default_lib_allocator::__rust_dealloc` at RUSTLIB/std/src/alloc.rs:LL:CC
3028
= note: inside `<std::boxed::Box<i32> as std::ops::Drop>::drop` at RUSTLIB/alloc/src/boxed.rs:LL:CC
3129
= note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
3230
= note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC

‎src/tools/miri/tests/fail/both_borrows/zero-sized-protected.tree.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: deallocation through <TAG> (root of the allocation) at ALLOC[0x0] is forbidden
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
2+
--> tests/fail/both_borrows/zero-sized-protected.rs:LL:CC
33
|
4-
LL | unsafe { libc::free(ptr as *mut libc::c_void) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> (root of the allocation) at ALLOC[0x0] is forbidden
4+
LL | unsafe { dealloc(ptr, l) };
5+
| ^^^^^^^^^^^^^^^ deallocation through <TAG> (root of the allocation) at ALLOC[0x0] is forbidden
66
|
77
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
88
= help: the allocation of the accessed tag <TAG> (root of the allocation) also contains the strongly protected tag <TAG>
@@ -18,13 +18,7 @@ help: the strongly protected tag <TAG> was created here, in the initial state Re
1818
LL | fn test(_x: &mut (), ptr: *mut u8, l: Layout) {
1919
| ^^
2020
= note: BACKTRACE (of the first span):
21-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
22-
= note: inside `std::alloc::__default_lib_allocator::__rust_dealloc` at RUSTLIB/std/src/alloc.rs:LL:CC
23-
note: inside `test`
24-
--> tests/fail/both_borrows/zero-sized-protected.rs:LL:CC
25-
|
26-
LL | unsafe { dealloc(ptr, l) };
27-
| ^^^^^^^^^^^^^^^
21+
= note: inside `test` at tests/fail/both_borrows/zero-sized-protected.rs:LL:CC
2822
note: inside `main`
2923
--> tests/fail/both_borrows/zero-sized-protected.rs:LL:CC
3024
|

‎src/tools/miri/tests/fail/data_race/dealloc_read_race1.stderr

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
error: Undefined Behavior: Data race detected between (1) non-atomic read on thread `unnamed-ID` and (2) deallocation on thread `unnamed-ID` at ALLOC. (2) just happened here
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
2+
--> tests/fail/data_race/dealloc_read_race1.rs:LL:CC
33
|
4-
LL | unsafe { libc::free(ptr as *mut libc::c_void) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between (1) non-atomic read on thread `unnamed-ID` and (2) deallocation on thread `unnamed-ID` at ALLOC. (2) just happened here
4+
LL | / __rust_dealloc(
5+
LL | |
6+
LL | | ptr.0 as *mut _,
7+
LL | | std::mem::size_of::<usize>(),
8+
LL | | std::mem::align_of::<usize>(),
9+
LL | | );
10+
| |_____________^ Data race detected between (1) non-atomic read on thread `unnamed-ID` and (2) deallocation on thread `unnamed-ID` at ALLOC. (2) just happened here
611
|
712
help: and (1) occurred earlier here
813
--> tests/fail/data_race/dealloc_read_race1.rs:LL:CC
@@ -12,18 +17,7 @@ LL | let _val = *ptr.0;
1217
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
1318
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
1419
= note: BACKTRACE (of the first span) on thread `unnamed-ID`:
15-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
16-
= note: inside `std::alloc::__default_lib_allocator::__rust_dealloc` at RUSTLIB/std/src/alloc.rs:LL:CC
17-
note: inside closure
18-
--> tests/fail/data_race/dealloc_read_race1.rs:LL:CC
19-
|
20-
LL | / __rust_dealloc(
21-
LL | |
22-
LL | | ptr.0 as *mut _,
23-
LL | | std::mem::size_of::<usize>(),
24-
LL | | std::mem::align_of::<usize>(),
25-
LL | | );
26-
| |_____________^
20+
= note: inside closure at tests/fail/data_race/dealloc_read_race1.rs:LL:CC
2721

2822
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2923

‎src/tools/miri/tests/fail/data_race/dealloc_write_race1.stderr

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
error: Undefined Behavior: Data race detected between (1) non-atomic write on thread `unnamed-ID` and (2) deallocation on thread `unnamed-ID` at ALLOC. (2) just happened here
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
2+
--> tests/fail/data_race/dealloc_write_race1.rs:LL:CC
33
|
4-
LL | unsafe { libc::free(ptr as *mut libc::c_void) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between (1) non-atomic write on thread `unnamed-ID` and (2) deallocation on thread `unnamed-ID` at ALLOC. (2) just happened here
4+
LL | / __rust_dealloc(
5+
LL | |
6+
LL | | ptr.0 as *mut _,
7+
LL | | std::mem::size_of::<usize>(),
8+
LL | | std::mem::align_of::<usize>(),
9+
LL | | );
10+
| |_____________^ Data race detected between (1) non-atomic write on thread `unnamed-ID` and (2) deallocation on thread `unnamed-ID` at ALLOC. (2) just happened here
611
|
712
help: and (1) occurred earlier here
813
--> tests/fail/data_race/dealloc_write_race1.rs:LL:CC
@@ -12,18 +17,7 @@ LL | *ptr.0 = 2;
1217
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
1318
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
1419
= note: BACKTRACE (of the first span) on thread `unnamed-ID`:
15-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
16-
= note: inside `std::alloc::__default_lib_allocator::__rust_dealloc` at RUSTLIB/std/src/alloc.rs:LL:CC
17-
note: inside closure
18-
--> tests/fail/data_race/dealloc_write_race1.rs:LL:CC
19-
|
20-
LL | / __rust_dealloc(
21-
LL | |
22-
LL | | ptr.0 as *mut _,
23-
LL | | std::mem::size_of::<usize>(),
24-
LL | | std::mem::align_of::<usize>(),
25-
LL | | );
26-
| |_____________^
20+
= note: inside closure at tests/fail/data_race/dealloc_write_race1.rs:LL:CC
2721

2822
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2923

‎src/tools/miri/tests/fail/memleak.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
error: memory leaked: ALLOC (C heap, size: 4, align: 4), allocated here:
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
3-
|
4-
LL | unsafe { libc::malloc(layout.size()) as *mut u8 }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: BACKTRACE:
8-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::alloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
9-
= note: inside `std::alloc::__default_lib_allocator::__rust_alloc` at RUSTLIB/std/src/alloc.rs:LL:CC
10-
note: inside `main`
1+
error: memory leaked: ALLOC (Rust heap, size: 4, align: 4), allocated here:
112
--> tests/fail/memleak.rs:LL:CC
123
|
134
LL | std::mem::forget(Box::new(42));
145
| ^^^^^^^^^^^^
6+
|
7+
= note: BACKTRACE:
8+
= note: inside `main` at tests/fail/memleak.rs:LL:CC
159

1610
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1711

‎src/tools/miri/tests/fail/memleak_no_backtrace.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: memory leaked: ALLOC (C heap, size: 4, align: 4)
1+
error: memory leaked: ALLOC (Rust heap, size: 4, align: 4)
22

33
note: set `MIRIFLAGS=-Zmiri-ignore-leaks` to disable this check
44

‎src/tools/miri/tests/fail/memleak_rc.stderr

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
error: memory leaked: ALLOC (C heap, size: 32, align: 16), allocated here:
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
1+
error: memory leaked: ALLOC (Rust heap, SIZE, ALIGN), allocated here:
2+
--> RUSTLIB/alloc/src/rc.rs:LL:CC
33
|
4-
LL | unsafe { libc::malloc(layout.size()) as *mut u8 }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | Box::leak(Box::new(RcInner { strong: Cell::new(1), weak: Cell::new(1), value }))
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: BACKTRACE:
8-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::alloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
9-
= note: inside `std::alloc::__default_lib_allocator::__rust_alloc` at RUSTLIB/std/src/alloc.rs:LL:CC
108
= note: inside `std::rc::Rc::<std::cell::RefCell<std::option::Option<Dummy>>>::new` at RUSTLIB/alloc/src/rc.rs:LL:CC
119
note: inside `main`
1210
--> tests/fail/memleak_rc.rs:LL:CC

‎src/tools/miri/tests/fail/stacked_borrows/deallocate_against_protector1.stderr

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
error: Undefined Behavior: deallocating while item [Unique for <TAG>] is strongly protected
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
2+
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
33
|
4-
LL | unsafe { libc::free(ptr as *mut libc::c_void) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating while item [Unique for <TAG>] is strongly protected
4+
LL | self.1.deallocate(From::from(ptr.cast()), layout);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating while item [Unique for <TAG>] is strongly protected
66
|
77
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
88
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
99
= note: BACKTRACE:
10-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
11-
= note: inside `std::alloc::__default_lib_allocator::__rust_dealloc` at RUSTLIB/std/src/alloc.rs:LL:CC
1210
= note: inside `<std::boxed::Box<i32> as std::ops::Drop>::drop` at RUSTLIB/alloc/src/boxed.rs:LL:CC
1311
= note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
1412
= note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC

‎src/tools/miri/tests/fail/stacked_borrows/illegal_dealloc1.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: attempting deallocation using <TAG> at ALLOC, but that tag does not exist in the borrow stack for this location
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
2+
--> tests/fail/stacked_borrows/illegal_deALLOC.rs:LL:CC
33
|
4-
LL | unsafe { libc::free(ptr as *mut libc::c_void) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempting deallocation using <TAG> at ALLOC, but that tag does not exist in the borrow stack for this location
4+
LL | dealloc(ptr2, Layout::from_size_align_unchecked(1, 1));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempting deallocation using <TAG> at ALLOC, but that tag does not exist in the borrow stack for this location
66
|
77
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
88
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
@@ -17,13 +17,7 @@ help: <TAG> was later invalidated at offsets [0x0..0x1] by a write access
1717
LL | ptr1.write(0);
1818
| ^^^^^^^^^^^^^
1919
= note: BACKTRACE (of the first span):
20-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
21-
= note: inside `std::alloc::__default_lib_allocator::__rust_dealloc` at RUSTLIB/std/src/alloc.rs:LL:CC
22-
note: inside `main`
23-
--> tests/fail/stacked_borrows/illegal_deALLOC.rs:LL:CC
24-
|
25-
LL | dealloc(ptr2, Layout::from_size_align_unchecked(1, 1));
26-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
= note: inside `main` at tests/fail/stacked_borrows/illegal_deALLOC.rs:LL:CC
2721

2822
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2923

‎src/tools/miri/tests/fail/tls_macro_leak.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
error: memory leaked: ALLOC (C heap, size: 4, align: 4), allocated here:
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
3-
|
4-
LL | unsafe { libc::malloc(layout.size()) as *mut u8 }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: BACKTRACE:
8-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::alloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
9-
= note: inside `std::alloc::__default_lib_allocator::__rust_alloc` at RUSTLIB/std/src/alloc.rs:LL:CC
10-
note: inside closure
1+
error: memory leaked: ALLOC (Rust heap, size: 4, align: 4), allocated here:
112
--> tests/fail/tls_macro_leak.rs:LL:CC
123
|
134
LL | cell.set(Some(Box::leak(Box::new(123))));
145
| ^^^^^^^^^^^^^
6+
|
7+
= note: BACKTRACE:
8+
= note: inside closure at tests/fail/tls_macro_leak.rs:LL:CC
159
= note: inside `std::thread::LocalKey::<std::cell::Cell<std::option::Option<&i32>>>::try_with::<{closure@tests/fail/tls_macro_leak.rs:LL:CC}, ()>` at RUSTLIB/std/src/thread/local.rs:LL:CC
1610
= note: inside `std::thread::LocalKey::<std::cell::Cell<std::option::Option<&i32>>>::with::<{closure@tests/fail/tls_macro_leak.rs:LL:CC}, ()>` at RUSTLIB/std/src/thread/local.rs:LL:CC
1711
note: inside closure

‎src/tools/miri/tests/fail/tls_static_leak.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
error: memory leaked: ALLOC (C heap, size: 4, align: 4), allocated here:
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
3-
|
4-
LL | unsafe { libc::malloc(layout.size()) as *mut u8 }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: BACKTRACE:
8-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::alloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
9-
= note: inside `std::alloc::__default_lib_allocator::__rust_alloc` at RUSTLIB/std/src/alloc.rs:LL:CC
10-
note: inside closure
1+
error: memory leaked: ALLOC (Rust heap, size: 4, align: 4), allocated here:
112
--> tests/fail/tls_static_leak.rs:LL:CC
123
|
134
LL | TLS.set(Some(Box::leak(Box::new(123))));
145
| ^^^^^^^^^^^^^
6+
|
7+
= note: BACKTRACE:
8+
= note: inside closure at tests/fail/tls_static_leak.rs:LL:CC
159

1610
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1711

‎src/tools/miri/tests/fail/tree_borrows/strongly-protected.stderr

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: deallocation through <TAG> at ALLOC[0x0] is forbidden
2-
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
2+
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
33
|
4-
LL | unsafe { libc::free(ptr as *mut libc::c_void) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden
4+
LL | self.1.deallocate(From::from(ptr.cast()), layout);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden
66
|
77
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
88
= help: the allocation of the accessed tag <TAG> also contains the strongly protected tag <TAG>
@@ -18,8 +18,6 @@ help: the strongly protected tag <TAG> was created here, in the initial state Re
1818
LL | fn inner(x: &mut i32, f: fn(*mut i32)) {
1919
| ^
2020
= note: BACKTRACE (of the first span):
21-
= note: inside `std::sys::alloc::unix::<impl std::alloc::GlobalAlloc for std::alloc::System>::dealloc` at RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
22-
= note: inside `std::alloc::__default_lib_allocator::__rust_dealloc` at RUSTLIB/std/src/alloc.rs:LL:CC
2321
= note: inside `<std::boxed::Box<i32> as std::ops::Drop>::drop` at RUSTLIB/alloc/src/boxed.rs:LL:CC
2422
= note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
2523
= note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC

‎src/tools/miri/tests/fail/uninit/uninit_alloc_diagnostic.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | drop(slice1.cmp(slice2));
1616
| ^^^^^^^^^^^^^^^^^^
1717

1818
Uninitialized memory occurred at ALLOC[0x4..0x10], in this allocation:
19-
ALLOC (C heap, size: 32, align: 16) {
19+
ALLOC (Rust heap, size: 32, align: 8) {
2020
0x00 │ 41 42 43 44 __ __ __ __ __ __ __ __ __ __ __ __ │ ABCD░░░░░░░░░░░░
2121
0x10 │ 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ .░░░░░░░░░░░░░░░
2222
}

‎src/tools/miri/tests/fail/uninit/uninit_alloc_diagnostic_with_provenance.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | drop(slice1.cmp(slice2));
1616
| ^^^^^^^^^^^^^^^^^^
1717

1818
Uninitialized memory occurred at ALLOC[0x4..0x8], in this allocation:
19-
ALLOC (C heap, size: 16, align: 16) {
19+
ALLOC (Rust heap, size: 16, align: 8) {
2020
╾42[ALLOC]<TAG> (1 ptr byte)╼ 12 13 ╾43[ALLOC]<TAG> (1 ptr byte)╼ __ __ __ __ __ __ __ __ __ __ __ __ │ ━..━░░░░░░░░░░░░
2121
}
2222
ALLOC (global (static or const), size: 1, align: 1) {

0 commit comments

Comments
 (0)
Please sign in to comment.