Skip to content

Commit 30e8618

Browse files
committed
Auto merge of #130303 - Zalathar:rollup-8vsqdox, r=Zalathar
Rollup of 3 pull requests Successful merges: - #130245 (make basic allocation functions track_caller in Miri for nicer backtraces) - #130261 (skip target sanity check when it's a `local-rebuild`) - #130287 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 9)) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b2f11d6 + 144f401 commit 30e8618

26 files changed

+65
-156
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use std::alloc::{alloc, dealloc, Layout};
22

3-
//@error-in-other-file: has size 1 and alignment 1, but gave size 1 and alignment 2
4-
53
fn main() {
64
unsafe {
75
let x = alloc(Layout::from_size_align_unchecked(1, 1));
8-
dealloc(x, Layout::from_size_align_unchecked(1, 2));
6+
dealloc(x, Layout::from_size_align_unchecked(1, 2)); //~ERROR: has size 1 and alignment 1, but gave size 1 and alignment 2
97
}
108
}

tests/fail/alloc/deallocate-bad-alignment.stderr

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN
2-
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
2+
--> $DIR/deallocate-bad-alignment.rs:LL:CC
33
|
4-
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN
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
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::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
11-
note: inside `main`
12-
--> $DIR/deallocate-bad-alignment.rs:LL:CC
13-
|
14-
LL | dealloc(x, Layout::from_size_align_unchecked(1, 2));
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/deallocate-bad-alignment.rs:LL:CC
1611

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use std::alloc::{alloc, dealloc, Layout};
22

3-
//@error-in-other-file: has size 1 and alignment 1, but gave size 2 and alignment 1
4-
53
fn main() {
64
unsafe {
75
let x = alloc(Layout::from_size_align_unchecked(1, 1));
8-
dealloc(x, Layout::from_size_align_unchecked(2, 1));
6+
dealloc(x, Layout::from_size_align_unchecked(2, 1)); //~ERROR: has size 1 and alignment 1, but gave size 2 and alignment 1
97
}
108
}

tests/fail/alloc/deallocate-bad-size.stderr

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
2-
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
2+
--> $DIR/deallocate-bad-size.rs:LL:CC
33
|
4-
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
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
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::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
11-
note: inside `main`
12-
--> $DIR/deallocate-bad-size.rs:LL:CC
13-
|
14-
LL | dealloc(x, Layout::from_size_align_unchecked(2, 1));
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/deallocate-bad-size.rs:LL:CC
1611

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

tests/fail/alloc/deallocate-twice.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use std::alloc::{alloc, dealloc, Layout};
22

3-
//@error-in-other-file: has been freed
4-
53
fn main() {
64
unsafe {
75
let x = alloc(Layout::from_size_align_unchecked(1, 1));
86
dealloc(x, Layout::from_size_align_unchecked(1, 1));
9-
dealloc(x, Layout::from_size_align_unchecked(1, 1));
7+
dealloc(x, Layout::from_size_align_unchecked(1, 1)); //~ERROR: has been freed
108
}
119
}

tests/fail/alloc/deallocate-twice.stderr

+4-9
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/alloc/src/alloc.rs:LL:CC
2+
--> $DIR/deallocate-twice.rs:LL:CC
33
|
4-
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
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,12 +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::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
21-
note: inside `main`
22-
--> $DIR/deallocate-twice.rs:LL:CC
23-
|
24-
LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
25-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
= note: inside `main` at $DIR/deallocate-twice.rs:LL:CC
2621

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use std::alloc::{alloc, realloc, Layout};
22

3-
//@error-in-other-file: has size 1 and alignment 1, but gave size 2 and alignment 1
4-
53
fn main() {
64
unsafe {
75
let x = alloc(Layout::from_size_align_unchecked(1, 1));
8-
let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
6+
let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1); //~ERROR: has size 1 and alignment 1, but gave size 2 and alignment 1
97
}
108
}

tests/fail/alloc/reallocate-bad-size.stderr

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
2-
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
2+
--> $DIR/reallocate-bad-size.rs:LL:CC
33
|
4-
LL | unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
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
|
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::alloc::realloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
11-
note: inside `main`
12-
--> $DIR/reallocate-bad-size.rs:LL:CC
13-
|
14-
LL | let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/reallocate-bad-size.rs:LL:CC
1611

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use std::alloc::{alloc, dealloc, realloc, Layout};
22

3-
//@error-in-other-file: has been freed
4-
53
fn main() {
64
unsafe {
75
let x = alloc(Layout::from_size_align_unchecked(1, 1));
86
dealloc(x, Layout::from_size_align_unchecked(1, 1));
9-
let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
7+
let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1); //~ERROR: has been freed
108
}
119
}

tests/fail/alloc/reallocate-dangling.stderr

+4-9
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/alloc/src/alloc.rs:LL:CC
2+
--> $DIR/reallocate-dangling.rs:LL:CC
33
|
4-
LL | unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) }
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,12 +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::alloc::realloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
21-
note: inside `main`
22-
--> $DIR/reallocate-dangling.rs:LL:CC
23-
|
24-
LL | let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
25-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
= note: inside `main` at $DIR/reallocate-dangling.rs:LL:CC
2621

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

tests/fail/alloc/stack_free.stderr

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
error: Undefined Behavior: deallocating ALLOC, which is stack variable memory, using Rust heap deallocation operation
2-
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
2+
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
33
|
4-
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating ALLOC, which is stack variable memory, using Rust 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::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
11-
= note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/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

tests/fail/both_borrows/newtype_pair_retagging.tree.stderr

+3-5
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/alloc/src/alloc.rs:LL:CC
2+
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
33
|
4-
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
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::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
29-
= note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/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

tests/fail/both_borrows/newtype_retagging.tree.stderr

+3-5
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/alloc/src/alloc.rs:LL:CC
2+
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
33
|
4-
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
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::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
29-
= note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/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

tests/fail/both_borrows/zero-sized-protected.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
//@revisions: stack tree
22
//@[tree]compile-flags: -Zmiri-tree-borrows
3-
//@[tree]error-in-other-file: /deallocation .* is forbidden/
43
use std::alloc::{alloc, dealloc, Layout};
54

65
// `x` is strongly protected but covers zero bytes.
76
// Let's see if deallocating the allocation x points to is UB:
87
// in TB, it is UB, but in SB it is not.
98
fn test(_x: &mut (), ptr: *mut u8, l: Layout) {
10-
unsafe { dealloc(ptr, l) };
9+
unsafe { dealloc(ptr, l) }; //~[tree] ERROR: /deallocation .* is forbidden/
1110
}
1211

1312
fn main() {

tests/fail/both_borrows/zero-sized-protected.tree.stderr

+4-9
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/alloc/src/alloc.rs:LL:CC
2+
--> $DIR/zero-sized-protected.rs:LL:CC
33
|
4-
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
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,12 +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::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
22-
note: inside `test`
23-
--> $DIR/zero-sized-protected.rs:LL:CC
24-
|
25-
LL | unsafe { dealloc(ptr, l) };
26-
| ^^^^^^^^^^^^^^^
21+
= note: inside `test` at $DIR/zero-sized-protected.rs:LL:CC
2722
note: inside `main`
2823
--> $DIR/zero-sized-protected.rs:LL:CC
2924
|

tests/fail/memleak.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
//@error-in-other-file: memory leaked
21
//@normalize-stderr-test: ".*│.*" -> "$$stripped$$"
32

43
fn main() {
5-
std::mem::forget(Box::new(42));
4+
std::mem::forget(Box::new(42)); //~ERROR: memory leaked
65
}

tests/fail/memleak.stderr

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
error: memory leaked: ALLOC (Rust heap, size: 4, align: 4), allocated here:
2-
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
3-
|
4-
LL | __rust_alloc(layout.size(), layout.align())
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: BACKTRACE:
8-
= note: inside `std::alloc::alloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
9-
= note: inside `std::alloc::Global::alloc_impl` at RUSTLIB/alloc/src/alloc.rs:LL:CC
10-
= note: inside `<std::alloc::Global as std::alloc::Allocator>::allocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
11-
= note: inside `alloc::alloc::exchange_malloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
12-
= note: inside `std::boxed::Box::<i32>::new` at RUSTLIB/alloc/src/boxed.rs:LL:CC
13-
note: inside `main`
142
--> $DIR/memleak.rs:LL:CC
153
|
164
LL | std::mem::forget(Box::new(42));
175
| ^^^^^^^^^^^^
6+
|
7+
= note: BACKTRACE:
8+
= note: inside `main` at $DIR/memleak.rs:LL:CC
189

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

tests/fail/memleak_rc.stderr

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
error: memory leaked: ALLOC (Rust heap, SIZE, ALIGN), allocated here:
2-
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
2+
--> RUSTLIB/alloc/src/rc.rs:LL:CC
33
|
4-
LL | __rust_alloc(layout.size(), layout.align())
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | Box::leak(Box::new(RcBox { strong: Cell::new(1), weak: Cell::new(1), value }))
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: BACKTRACE:
8-
= note: inside `std::alloc::alloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
9-
= note: inside `std::alloc::Global::alloc_impl` at RUSTLIB/alloc/src/alloc.rs:LL:CC
10-
= note: inside `<std::alloc::Global as std::alloc::Allocator>::allocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
11-
= note: inside `alloc::alloc::exchange_malloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
12-
= note: inside `std::boxed::Box::<std::rc::RcBox<std::cell::RefCell<std::option::Option<Dummy>>>>::new` at RUSTLIB/alloc/src/boxed.rs:LL:CC
138
= note: inside `std::rc::Rc::<std::cell::RefCell<std::option::Option<Dummy>>>::new` at RUSTLIB/alloc/src/rc.rs:LL:CC
149
note: inside `main`
1510
--> $DIR/memleak_rc.rs:LL:CC

tests/fail/stacked_borrows/deallocate_against_protector1.stderr

+3-5
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/alloc/src/alloc.rs:LL:CC
2+
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
33
|
4-
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
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::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
11-
= note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/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

0 commit comments

Comments
 (0)