@@ -59,21 +59,29 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
59
59
use std:: sync:: Mutex ;
60
60
61
61
use windows:: Win32 :: System :: Diagnostics :: Debug :: {
62
- SEM_NOGPFAULTERRORBOX , SetErrorMode , THREAD_ERROR_MODE ,
62
+ SEM_FAILCRITICALERRORS , SEM_NOGPFAULTERRORBOX , SetErrorMode , THREAD_ERROR_MODE ,
63
63
} ;
64
64
65
65
static LOCK : Mutex < ( ) > = Mutex :: new ( ( ) ) ;
66
66
67
67
// Error mode is a global variable, so lock it so only one thread will change it
68
68
let _lock = LOCK . lock ( ) . unwrap ( ) ;
69
69
70
- // Tell Windows to not show any UI on errors (such as terminating abnormally).
71
- // This is important for running tests, since some of them use abnormal
72
- // termination by design. This mode is inherited by all child processes.
70
+ // Tell Windows to not show any UI on errors (such as terminating abnormally). This is important
71
+ // for running tests, since some of them use abnormal termination by design. This mode is
72
+ // inherited by all child processes.
73
+ //
74
+ // Note that `run-make` tests require `SEM_FAILCRITICALERRORS` in addition to suppress Windows
75
+ // Error Reporting (WER) error dialogues that come from "critical failures" such as missing
76
+ // DLLs.
77
+ //
78
+ // See <https://github.com/rust-lang/rust/issues/132092> and
79
+ // <https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode?redirectedfrom=MSDN>.
73
80
unsafe {
74
- let old_mode = SetErrorMode ( SEM_NOGPFAULTERRORBOX ) ; // read inherited flags
81
+ // read inherited flags
82
+ let old_mode = SetErrorMode ( SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS ) ;
75
83
let old_mode = THREAD_ERROR_MODE ( old_mode) ;
76
- SetErrorMode ( old_mode | SEM_NOGPFAULTERRORBOX ) ;
84
+ SetErrorMode ( old_mode | SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS ) ;
77
85
let r = f ( ) ;
78
86
SetErrorMode ( old_mode) ;
79
87
r
0 commit comments