Skip to content

Commit 08bddfb

Browse files
committed
Bless miri tests
1 parent 1dd2f56 commit 08bddfb

29 files changed

+336
-159
lines changed

library/alloc/src/alloc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ use core::ptr::{self, NonNull};
1212

1313
extern "Rust" {
1414
// These are the magic symbols to call the global allocator. rustc generates
15-
// them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute
16-
// (the code expanding that attribute macro generates those functions), or to call
15+
// them to call `GLOBAL.alloc` etc. if there is a `#[global_allocator]` attribute
16+
// (the code expanding that attribute macro generates those functions), or if not
1717
// the default implementations in std (weak symbols in `library/std/src/alloc.rs`)
18-
// otherwise.
19-
// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them
20-
// like `malloc`, `realloc`, and `free`, respectively.
18+
// is used otherwise.
19+
// The rustc fork of LLVM 14 and earlier also special-cases these function names to
20+
// be able to optimize them like `malloc`, `realloc`, and `free`, respectively.
2121
#[rustc_allocator]
2222
#[rustc_nounwind]
2323
fn __rust_alloc(size: usize, align: usize) -> *mut u8;

src/tools/miri/tests/fail/alloc/alloc_error_handler.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | ABORT();
99
= note: inside `std::sys::pal::PLATFORM::abort_internal` at RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
1010
= note: inside `std::process::abort` at RUSTLIB/std/src/process.rs:LL:CC
1111
= note: inside `std::alloc::rust_oom` at RUSTLIB/std/src/alloc.rs:LL:CC
12-
= note: inside `std::alloc::_::__rg_oom` at RUSTLIB/std/src/alloc.rs:LL:CC
12+
= note: inside `std::alloc::_::__rust_alloc_error_handler` at RUSTLIB/std/src/alloc.rs:LL:CC
1313
= note: inside `std::alloc::handle_alloc_error::rt_error` at RUSTLIB/alloc/src/alloc.rs:LL:CC
1414
= note: inside `std::alloc::handle_alloc_error` at RUSTLIB/alloc/src/alloc.rs:LL:CC
1515
note: inside `main`

src/tools/miri/tests/fail/alloc/alloc_error_handler_custom.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | core::intrinsics::abort();
77
|
88
= note: BACKTRACE:
99
= note: inside `alloc_error_handler` at tests/fail/alloc/alloc_error_handler_custom.rs:LL:CC
10-
note: inside `_::__rg_oom`
10+
note: inside `_::__rust_alloc_error_handler`
1111
--> tests/fail/alloc/alloc_error_handler_custom.rs:LL:CC
1212
|
1313
LL | #[alloc_error_handler]

src/tools/miri/tests/fail/alloc/alloc_error_handler_no_std.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | core::intrinsics::abort();
99
|
1010
= note: BACKTRACE:
1111
= note: inside `panic_handler` at tests/fail/alloc/alloc_error_handler_no_std.rs:LL:CC
12-
= note: inside `alloc::alloc::__alloc_error_handler::__rdl_oom` at RUSTLIB/alloc/src/alloc.rs:LL:CC
12+
= note: inside `alloc::alloc::__alloc_error_handler::__rust_alloc_error_handler` at RUSTLIB/alloc/src/alloc.rs:LL:CC
1313
= note: inside `alloc::alloc::handle_alloc_error::rt_error` at RUSTLIB/alloc/src/alloc.rs:LL:CC
1414
= note: inside `alloc::alloc::handle_alloc_error` at RUSTLIB/alloc/src/alloc.rs:LL:CC
1515
note: inside `start`

src/tools/miri/tests/fail/alloc/deallocate-bad-alignment.stderr

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/tools/miri/tests/fail/alloc/deallocate-bad-size.stderr

Lines changed: 0 additions & 15 deletions
This file was deleted.

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

Lines changed: 10 additions & 4 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-
--> tests/fail/alloc/deallocate-twice.rs:LL:CC
2+
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
33
|
4-
LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
4+
LL | unsafe { libc::free(ptr as *mut libc::c_void) }
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,7 +17,13 @@ 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 `main` at tests/fail/alloc/deallocate-twice.rs:LL:CC
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+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2127

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

src/tools/miri/tests/fail/alloc/global_system_mixup.stderr

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
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
1+
error: memory leaked: ALLOC (C heap, size: 1, align: 1), allocated here:
2+
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
33
|
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
4+
LL | unsafe { libc::realloc(ptr as *mut libc::c_void, new_size) as *mut u8 }
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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
97
= note: BACKTRACE:
10-
= note: inside `main` at tests/fail/alloc/reallocate-bad-size.rs:LL:CC
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+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1115

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

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

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

Lines changed: 10 additions & 4 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-
--> tests/fail/alloc/reallocate-dangling.rs:LL:CC
2+
--> RUSTLIB/std/src/sys/alloc/unix.rs:LL:CC
33
|
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
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
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,7 +17,13 @@ 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 `main` at tests/fail/alloc/reallocate-dangling.rs:LL:CC
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+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2127

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

0 commit comments

Comments
 (0)