@@ -59,21 +59,29 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
5959 use std:: sync:: Mutex ;
6060
6161 use windows:: Win32 :: System :: Diagnostics :: Debug :: {
62- SEM_NOGPFAULTERRORBOX , SetErrorMode , THREAD_ERROR_MODE ,
62+ SEM_FAILCRITICALERRORS , SEM_NOGPFAULTERRORBOX , SetErrorMode , THREAD_ERROR_MODE ,
6363 } ;
6464
6565 static LOCK : Mutex < ( ) > = Mutex :: new ( ( ) ) ;
6666
6767 // Error mode is a global variable, so lock it so only one thread will change it
6868 let _lock = LOCK . lock ( ) . unwrap ( ) ;
6969
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>.
7380 unsafe {
74- let old_mode = SetErrorMode ( SEM_NOGPFAULTERRORBOX ) ; // read inherited flags
81+ // read inherited flags
82+ let old_mode = SetErrorMode ( SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS ) ;
7583 let old_mode = THREAD_ERROR_MODE ( old_mode) ;
76- SetErrorMode ( old_mode | SEM_NOGPFAULTERRORBOX ) ;
84+ SetErrorMode ( old_mode | SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS ) ;
7785 let r = f ( ) ;
7886 SetErrorMode ( old_mode) ;
7987 r
0 commit comments