Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1084857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:36:56+00:00 2026-05-16T22:36:56+00:00

I’m trying to write a test suite for a compiler (LLVM) and it works

  • 0

I’m trying to write a test suite for a compiler (LLVM) and it works perfectly fine on every platform except for Windows. On Windows I get the “critical-error-handler” message box which stops the tests indefinitely.

This problem makes it very difficult to test because, with compilers, a problem often means invalid code on the assembly level, and thus crazy, unpredictable errors.

I found During a subprocess call, catch critical windows errors in Python instead of letting the OS handle it by showing nasty error pop-ups while searching for the answer, but this doesn’t work for me. I still get the message boxes when testing.

The documentation on [SetErrorMode](http://msdn.microsoft.com/en-us/library/ms680621(VS100).aspx) Says that:

SEM_FAILCRITICALERRORS:
The system does not display the critical-error-handler message box. Instead, the system sends the error to the calling process.

SEM_NOGPFAULTERRORBOX:
The system does not display the Windows Error Reporting dialog.

Each process has an associated error mode that indicates to the system how the application is going to respond to serious errors. A child process inherits the error mode of its parent process.

However, after calling SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX) and launching the process with CreateProcess with dwCreationFlags = CREATE_NEW_CONSOLE, I still get the boxes when subprocesses fail.

In case it matters, the exact Python code I am using is:

import ctypes
# 3 is SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX
ctypes.windll.kernel32.SetErrorMode(3)

How do I fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:36:56+00:00Added an answer on May 16, 2026 at 10:36 pm

    The problem was actually Dr. Watson(link redacted), who rudely ignores SetErrorMode(link redacted). The only way to prevent Dr. Watson from stealing your joy is to prevent him from ever getting the call. There are two ways to do this.

    1. Call SetUnhandledExceptionHandler(yourexceptionhandler);

      If you call exit in this handler, the program terminates normally and Dr. Watson is never invoked.

      UnhandledExceptionFilter(LPEXCEPTION_POINTERS ep) {
        fputs("Application crashed with unhandled exception!\n", stderr);
      
        // Exit to prevent anything else from handling this exception.
        _exit(-3);
      }
      
      int main() {
        SetUnhandledExceptionFilter(UnhandledExceptionFilter);
      }
      

      This only works if you have access to the source code and feel like modifying it. In my case I had access to the source code, but it was a collection of a few hundred separate files, and so adding this code in all of them was a non starter. It also wouldn’t handle the case of an error before main, or just plain invalid executables.

    2. Run the process under a debugger using CreateProcess(..., DEBUG_PROCESS, ...)(link redacted) and WaitForDebugEvent(link redacted)

      When running a process like this, all exceptions are propagated to the debugger, and thus they can be handled appropriately.

      This is a rather complex solution to what should be a simple problem, but it is the only way I have found to completely block Dr. Watson. I am Currently writing a minimal program that tries to run the subprocess normally in every way except for catching unhandled exceptions. I will post a link here once it is committed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.