Skip to content

Commit 9c9c382

Browse files
committed
Auto merge of #122338 - workingjubilee:rollup-xzpt4v4, r=workingjubilee
Rollup of 15 pull requests Successful merges: - #116791 (Allow codegen backends to opt-out of parallel codegen) - #116793 (Allow targets to override default codegen backend) - #117458 (LLVM Bitcode Linker: A self contained linker for nvptx and other targets) - #119385 (Fix type resolution of associated const equality bounds (take 2)) - #121438 (std support for wasm32 panic=unwind) - #121893 (Add tests (and a bit of cleanup) for interior mut handling in promotion and const-checking) - #122080 (Clarity improvements to `DropTree`) - #122152 (Improve diagnostics for parenthesized type arguments) - #122166 (Remove the unused `field_remapping` field from `TypeLowering`) - #122249 (interpret: do not call machine read hooks during validation) - #122299 (Store backtrace for `must_produce_diag`) - #122318 (Revision-related tweaks for next-solver tests) - #122320 (Use ptradd for vtable indexing) - #122328 (unix_sigpipe: Replace `inherit` with `sig_dfl` in syntax tests) - #122330 (bootstrap readme: fix, improve, update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 65aed22 + 69e3694 commit 9c9c382

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

tests/pass/alloc-access-tracking.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#![feature(start)]
2+
#![no_std]
3+
//@compile-flags: -Zmiri-track-alloc-id=17 -Zmiri-track-alloc-accesses -Cpanic=abort
4+
//@only-target-linux: alloc IDs differ between OSes for some reason
5+
6+
extern "Rust" {
7+
fn miri_alloc(size: usize, align: usize) -> *mut u8;
8+
fn miri_dealloc(ptr: *mut u8, size: usize, align: usize);
9+
}
10+
11+
#[start]
12+
fn start(_: isize, _: *const *const u8) -> isize {
13+
unsafe {
14+
let ptr = miri_alloc(123, 1);
15+
*ptr = 42; // Crucially, only a write is printed here, no read!
16+
assert_eq!(*ptr, 42);
17+
miri_dealloc(ptr, 123, 1);
18+
}
19+
0
20+
}
21+
22+
#[panic_handler]
23+
fn panic_handler(_: &core::panic::PanicInfo) -> ! {
24+
loop {}
25+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
note: tracking was triggered
2+
--> $DIR/alloc-access-tracking.rs:LL:CC
3+
|
4+
LL | let ptr = miri_alloc(123, 1);
5+
| ^^^^^^^^^^^^^^^^^^ created Miri bare-metal heap allocation of 123 bytes (alignment ALIGN bytes) with id 17
6+
|
7+
= note: BACKTRACE:
8+
= note: inside `start` at $DIR/alloc-access-tracking.rs:LL:CC
9+
10+
note: tracking was triggered
11+
--> $DIR/alloc-access-tracking.rs:LL:CC
12+
|
13+
LL | *ptr = 42; // Crucially, only a write is printed here, no read!
14+
| ^^^^^^^^^ write access to allocation with id 17
15+
|
16+
= note: BACKTRACE:
17+
= note: inside `start` at $DIR/alloc-access-tracking.rs:LL:CC
18+
19+
note: tracking was triggered
20+
--> $DIR/alloc-access-tracking.rs:LL:CC
21+
|
22+
LL | assert_eq!(*ptr, 42);
23+
| ^^^^^^^^^^^^^^^^^^^^ read access to allocation with id 17
24+
|
25+
= note: BACKTRACE:
26+
= note: inside `start` at RUSTLIB/core/src/macros/mod.rs:LL:CC
27+
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
28+
29+
note: tracking was triggered
30+
--> $DIR/alloc-access-tracking.rs:LL:CC
31+
|
32+
LL | miri_dealloc(ptr, 123, 1);
33+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ freed allocation with id 17
34+
|
35+
= note: BACKTRACE:
36+
= note: inside `start` at $DIR/alloc-access-tracking.rs:LL:CC
37+

0 commit comments

Comments
 (0)