Skip to content

Commit be68e97

Browse files
committed
Auto merge of #3351 - RalfJung:diagnostic-dedup-considered-harmful, r=RalfJung
disable diagnostic deduplication `@oli-obk` is there a better way to do this? Ideally we'd only set this when interpretation starts but the value in the compiler session seems to be immutable. I assume people will do `cargo check` before `cargo miri` so hopefully this won't lead to too much confusion. Fixes #3350
2 parents 45bce48 + 7044a3e commit be68e97

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ environment variable. We first document the most relevant and most commonly used
318318
and `warn-nobacktrace` are the supported actions. The default is to `abort`,
319319
which halts the machine. Some (but not all) operations also support continuing
320320
execution with a "permission denied" error being returned to the program.
321-
`warn` prints a full backtrace when that happens; `warn-nobacktrace` is less
322-
verbose. `hide` hides the warning entirely.
321+
`warn` prints a full backtrace each time that happens; `warn-nobacktrace` is less
322+
verbose and shown at most once per operation. `hide` hides the warning entirely.
323323
* `-Zmiri-num-cpus` states the number of available CPUs to be reported by miri. By default, the
324324
number of available CPUs is `1`. Note that this flag does not affect how miri handles threads in
325325
any way.

src/helpers.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use std::cmp;
2+
use std::collections::BTreeSet;
23
use std::iter;
34
use std::num::NonZero;
5+
use std::sync::Mutex;
46
use std::time::Duration;
57

68
use rustc_apfloat::ieee::{Double, Single};
@@ -603,9 +605,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
603605
match reject_with {
604606
RejectOpWith::Abort => isolation_abort_error(op_name),
605607
RejectOpWith::WarningWithoutBacktrace => {
606-
this.tcx
607-
.dcx()
608-
.warn(format!("{op_name} was made to return an error due to isolation"));
608+
// This exists to reduce verbosity; make sure we emit the warning at most once per
609+
// operation.
610+
static EMITTED_WARNINGS: Mutex<BTreeSet<String>> = Mutex::new(BTreeSet::new());
611+
612+
let mut emitted_warnings = EMITTED_WARNINGS.lock().unwrap();
613+
if !emitted_warnings.contains(op_name) {
614+
// First time we are seeing this.
615+
emitted_warnings.insert(op_name.to_owned());
616+
this.tcx
617+
.dcx()
618+
.warn(format!("{op_name} was made to return an error due to isolation"));
619+
}
609620
Ok(())
610621
}
611622
RejectOpWith::Warning => {

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,7 @@ pub const MIRI_DEFAULT_ARGS: &[&str] = &[
143143
"-Zmir-keep-place-mention",
144144
"-Zmir-opt-level=0",
145145
"-Zmir-enable-passes=-CheckAlignment",
146+
// Deduplicating diagnostics means we miss events when tracking what happens during an
147+
// execution. Let's not do that.
148+
"-Zdeduplicate-diagnostics=no",
146149
];

tests/pass-dep/concurrency/linux-futex.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ fn wait_wake_bitset() {
219219
t.join().unwrap();
220220
}
221221

222+
// Crucial test which relies on the SeqCst fences in futex wait/wake.
222223
fn concurrent_wait_wake() {
223224
const FREE: i32 = 0;
224225
const HELD: i32 = 1;

0 commit comments

Comments
 (0)