Skip to content

Commit a45e3aa

Browse files
committed
Show the memory of uninit reads
1 parent 32e4d3a commit a45e3aa

File tree

79 files changed

+903
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+903
-113
lines changed

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ use std::mem;
22

33
use rustc_errors::{Diag, DiagArgName, DiagArgValue, DiagMessage, IntoDiagArg};
44
use rustc_middle::mir::AssertKind;
5-
use rustc_middle::mir::interpret::{Provenance, ReportedErrorInfo};
5+
use rustc_middle::mir::interpret::{Provenance, ReportedErrorInfo, UndefinedBehaviorInfo};
66
use rustc_middle::query::TyCtxtAt;
7+
use rustc_middle::ty::ConstInt;
78
use rustc_middle::ty::layout::LayoutError;
8-
use rustc_middle::ty::{ConstInt, TyCtxt};
99
use rustc_span::{Span, Symbol};
1010

1111
use super::CompileTimeMachine;
1212
use crate::errors::{self, FrameNote, ReportErrorExt};
1313
use crate::interpret::{
14-
ErrorHandled, Frame, InterpErrorInfo, InterpErrorKind, MachineStopType, err_inval,
14+
ErrorHandled, Frame, InterpCx, InterpErrorInfo, InterpErrorKind, MachineStopType, err_inval,
1515
err_machine_stop,
1616
};
1717

@@ -135,7 +135,7 @@ pub fn get_span_and_frames<'tcx>(
135135
/// You can use it to add a stacktrace of current execution according to
136136
/// `get_span_and_frames` or just give context on where the const eval error happened.
137137
pub(super) fn report<'tcx, C, F>(
138-
tcx: TyCtxt<'tcx>,
138+
ecx: &InterpCx<'tcx, CompileTimeMachine<'tcx>>,
139139
error: InterpErrorKind<'tcx>,
140140
span: Span,
141141
get_span_and_frames: C,
@@ -145,6 +145,7 @@ where
145145
C: FnOnce() -> (Span, Vec<FrameNote>),
146146
F: FnOnce(&mut Diag<'_>, Span, Vec<FrameNote>),
147147
{
148+
let tcx = ecx.tcx.tcx;
148149
// Special handling for certain errors
149150
match error {
150151
// Don't emit a new diagnostic for these errors, they are already reported elsewhere or
@@ -170,9 +171,24 @@ where
170171
InterpErrorKind::ResourceExhaustion(_) | InterpErrorKind::InvalidProgram(_)
171172
);
172173

174+
if let InterpErrorKind::UndefinedBehavior(UndefinedBehaviorInfo::InvalidUninitBytes(
175+
Some((alloc_id, _access)),
176+
)) = error
177+
{
178+
let bytes = ecx.print_alloc_bytes_for_diagnostics(alloc_id);
179+
let info = ecx.get_alloc_info(alloc_id);
180+
let raw_bytes = errors::RawBytesNote {
181+
size: info.size.bytes(),
182+
align: info.align.bytes(),
183+
bytes,
184+
};
185+
err.subdiagnostic(raw_bytes);
186+
}
187+
173188
error.add_args(&mut err);
174189

175190
mk(&mut err, span, frames);
191+
176192
let g = err.emit();
177193
let reported = if allowed_in_infallible {
178194
ReportedErrorInfo::allowed_in_infallible(g)

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,12 @@ pub fn eval_to_const_value_raw_provider<'tcx>(
293293

294294
// FIXME(oli-obk): why don't we have any tests for this code path?
295295
super::report(
296-
tcx,
296+
&InterpCx::new(
297+
tcx,
298+
tcx.def_span(def_id),
299+
key.typing_env,
300+
CompileTimeMachine::new(CanAccessMutGlobal::Yes, CheckAlignment::No),
301+
),
297302
error.into_kind(),
298303
span,
299304
|| (span, vec![]),
@@ -433,7 +438,7 @@ fn report_eval_error<'tcx>(
433438
let instance = with_no_trimmed_paths!(cid.instance.to_string());
434439

435440
super::report(
436-
*ecx.tcx,
441+
ecx,
437442
error,
438443
DUMMY_SP,
439444
|| super::get_span_and_frames(ecx.tcx, ecx.stack()),
@@ -473,7 +478,7 @@ fn report_validation_error<'tcx>(
473478
errors::RawBytesNote { size: info.size.bytes(), align: info.align.bytes(), bytes };
474479

475480
crate::const_eval::report(
476-
*ecx.tcx,
481+
ecx,
477482
error,
478483
DUMMY_SP,
479484
|| crate::const_eval::get_span_and_frames(ecx.tcx, ecx.stack()),
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
2+
--> tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
3+
|
4+
LL | libc::pthread_cond_destroy(cond.as_mut_ptr());
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
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-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
11+
12+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
13+
ALLOC (stack variable, size: 48, align: 4) {
14+
0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
15+
0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
16+
0x20 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
17+
}
18+
19+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
20+
21+
error: aborting due to 1 previous error
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
2+
--> tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
3+
|
4+
LL | libc::pthread_cond_destroy(cond.as_mut_ptr());
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
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-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
11+
12+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
13+
ALLOC (stack variable, size: 48, align: 8) {
14+
0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
15+
0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
16+
0x20 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
17+
}
18+
19+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
20+
21+
error: aborting due to 1 previous error
22+

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ignore-target: windows # No pthreads on Windows
2+
//@ stderr-per-bitwidth
23

34
/// Test that destroying a pthread_cond twice fails, even without a check for number validity
45
@@ -15,6 +16,6 @@ fn main() {
1516
libc::pthread_cond_destroy(cond.as_mut_ptr());
1617

1718
libc::pthread_cond_destroy(cond.as_mut_ptr());
18-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
19+
//~^ ERROR: /Undefined Behavior: .* but memory is uninitialized/
1920
}
2021
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.stderr

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
22
--> tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_cond_destroy(cond.as_mut_ptr());
@@ -9,6 +9,13 @@ LL | libc::pthread_cond_destroy(cond.as_mut_ptr());
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
13+
ALLOC (stack variable, size: 48, align: 8) {
14+
0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
15+
0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
16+
0x20 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
17+
}
18+
1219
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1320

1421
error: aborting due to 1 previous error

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ fn main() {
1313
libc::pthread_condattr_destroy(attr.as_mut_ptr());
1414

1515
libc::pthread_condattr_destroy(attr.as_mut_ptr());
16-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
16+
//~^ ERROR: /Undefined Behavior: .* but memory is uninitialized/
1717
}
1818
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
22
--> tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_condattr_destroy(attr.as_mut_ptr());
@@ -9,6 +9,11 @@ LL | libc::pthread_condattr_destroy(attr.as_mut_ptr());
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
13+
ALLOC (stack variable, size: 4, align: 4) {
14+
__ __ __ __ │ ░░░░
15+
}
16+
1217
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1318

1419
error: aborting due to 1 previous error
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
2+
--> tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.rs:LL:CC
3+
|
4+
LL | libc::pthread_mutex_destroy(mutex.as_mut_ptr());
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
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-dep/concurrency/libc_pthread_mutex_double_destroy.rs:LL:CC
11+
12+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
13+
ALLOC (stack variable, size: 24, align: 4) {
14+
0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
15+
0x10 │ __ __ __ __ __ __ __ __ │ ░░░░░░░░
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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
2+
--> tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.rs:LL:CC
3+
|
4+
LL | libc::pthread_mutex_destroy(mutex.as_mut_ptr());
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
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-dep/concurrency/libc_pthread_mutex_double_destroy.rs:LL:CC
11+
12+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
13+
ALLOC (stack variable, size: 40, align: 8) {
14+
0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
15+
0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
16+
0x20 │ __ __ __ __ __ __ __ __ │ ░░░░░░░░
17+
}
18+
19+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
20+
21+
error: aborting due to 1 previous error
22+

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ignore-target: windows # No pthreads on Windows
2+
//@ stderr-per-bitwidth
23

34
/// Test that destroying a pthread_mutex twice fails, even without a check for number validity
45
@@ -16,6 +17,6 @@ fn main() {
1617
libc::pthread_mutex_destroy(mutex.as_mut_ptr());
1718

1819
libc::pthread_mutex_destroy(mutex.as_mut_ptr());
19-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
20+
//~^ ERROR: /Undefined Behavior: .* but memory is uninitialized/
2021
}
2122
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.stderr

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
22
--> tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_mutex_destroy(mutex.as_mut_ptr());
@@ -9,6 +9,13 @@ LL | libc::pthread_mutex_destroy(mutex.as_mut_ptr());
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
13+
ALLOC (stack variable, size: 40, align: 8) {
14+
0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
15+
0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
16+
0x20 │ __ __ __ __ __ __ __ __ │ ░░░░░░░░
17+
}
18+
1219
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1320

1421
error: aborting due to 1 previous error

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_mutexattr_double_destroy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ fn main() {
1212
libc::pthread_mutexattr_destroy(attr.as_mut_ptr());
1313

1414
libc::pthread_mutexattr_destroy(attr.as_mut_ptr());
15-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
15+
//~^ ERROR: /Undefined Behavior: .* but memory is uninitialized/
1616
}
1717
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_mutexattr_double_destroy.stderr

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
22
--> tests/fail-dep/concurrency/libc_pthread_mutexattr_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_mutexattr_destroy(attr.as_mut_ptr());
@@ -9,6 +9,11 @@ LL | libc::pthread_mutexattr_destroy(attr.as_mut_ptr());
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_mutexattr_double_destroy.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
13+
ALLOC (stack variable, size: 4, align: 4) {
14+
__ __ __ __ │ ░░░░
15+
}
16+
1217
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1318

1419
error: aborting due to 1 previous error
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
2+
--> tests/fail-dep/concurrency/libc_pthread_rwlock_double_destroy.rs:LL:CC
3+
|
4+
LL | libc::pthread_rwlock_destroy(&mut lock);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
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-dep/concurrency/libc_pthread_rwlock_double_destroy.rs:LL:CC
11+
12+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
13+
ALLOC (stack variable, size: 32, align: 4) {
14+
0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
15+
0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
2+
--> tests/fail-dep/concurrency/libc_pthread_rwlock_double_destroy.rs:LL:CC
3+
|
4+
LL | libc::pthread_rwlock_destroy(&mut lock);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
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-dep/concurrency/libc_pthread_rwlock_double_destroy.rs:LL:CC
11+
12+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
13+
ALLOC (stack variable, size: 56, align: 8) {
14+
0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
15+
0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
16+
0x20 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
17+
0x30 │ __ __ __ __ __ __ __ __ │ ░░░░░░░░
18+
}
19+
20+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
21+
22+
error: aborting due to 1 previous error
23+

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_rwlock_double_destroy.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ignore-target: windows # No pthreads on Windows
2+
//@ stderr-per-bitwidth
23

34
/// Test that destroying a pthread_rwlock twice fails, even without a check for number validity
45
@@ -9,6 +10,6 @@ fn main() {
910
libc::pthread_rwlock_destroy(&mut lock);
1011

1112
libc::pthread_rwlock_destroy(&mut lock);
12-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
13+
//~^ ERROR: /Undefined Behavior: .* but memory is uninitialized/
1314
}
1415
}

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_rwlock_double_destroy.stderr

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0x0..0x4], but memory is uninitialized at [0x0..0x4], and this operation requires initialized memory
22
--> tests/fail-dep/concurrency/libc_pthread_rwlock_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_rwlock_destroy(&mut lock);
@@ -9,6 +9,14 @@ LL | libc::pthread_rwlock_destroy(&mut lock);
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_rwlock_double_destroy.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0x0..0x4], in this allocation:
13+
ALLOC (stack variable, size: 56, align: 8) {
14+
0x00 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
15+
0x10 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
16+
0x20 │ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ ░░░░░░░░░░░░░░░░
17+
0x30 │ __ __ __ __ __ __ __ __ │ ░░░░░░░░
18+
}
19+
1220
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1321

1422
error: aborting due to 1 previous error

0 commit comments

Comments
 (0)