SetUnhandledExceptionFilter not working in QEventLoop

  • Hello there,

    I have a problem with SetUnhandledExceptionFilter in my Windows APP.

    I'm successfully using BreakPad in my console app for all platforms and everything works ok.Today I found out that crash handler doesn't work in Windows GUI app. After some testing I found out that problem isn't in BreakPad, but directly in SetUnhandledExceptionFilter.

    So I wrote following test code:

    @extern long __stdcall filter(EXCEPTION_POINTERS *p)
    qDebug() << "App CRASH";
    return 0;

    int buggyFunc()
    delete reinterpret_cast<QString*>(0xFEE1DEAD);
    return 0;

    int main(int argc, char * argv[])
    QApplication app(argc, argv);
    qDebug() << "App start";

    SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER) filter);
    qDebug() << "CrashHandlerSet";

    //When I crash app here, crash handler is correctly executed

    Dialog dlg;
    dlg.exec(); //but when I call the same buggyFunc anywhere in the Dialog, application crash without executing filter

    //When I crash app here, crash handler is correctly executed too
    return 0;

    Crash handler stop working while QEventLoop is executed. As soon as event loop is exited, everything works correctly. I also test if ExceptionFilter is correctly set inside the Dialog event loop. The filter is correctly set also inside the Dialog.

    @void Dialog::on_pushButton_clicked()
    LPTOP_LEVEL_EXCEPTION_FILTER filter = SetUnhandledExceptionFilter(NULL);
    //filter = 0x000000013f6496ab filter(struct _EXCEPTION_POINTERS * ptr64)
    delete reinterpret_cast<QString*>(0xFEE1DEAD);

    I tried Debug and also Release version of App but none of them work (I tried it with attached and detached debugger and of course executed separately from Visual studio).

    I will be appreciated for any help.

  • After next searching I found that this problem occurs only on 64-bit windows. On 32-bit everything works ok too.

  • I had the same problem as ludek, because I'm using a 64-bit Windows. but as it mentioned in this blog( it is sufficient to execute this function to enable crashing:
    @void enableCrashingOnCrashes()
    typedef BOOL (WINAPI *tGetPolicy)(LPDWORD lpFlags);
    typedef BOOL (WINAPI *tSetPolicy)(DWORD dwFlags);

    HMODULE kernel32 = LoadLibraryA("kernel32.dll");
    tGetPolicy pGetPolicy = (tGetPolicy)GetProcAddress(kernel32,
    tSetPolicy pSetPolicy = (tSetPolicy)GetProcAddress(kernel32,
    if (pGetPolicy && pSetPolicy)
        DWORD dwFlags;
        if (pGetPolicy(&dwFlags))
            // Turn off the filter
            pSetPolicy(dwFlags & ~EXCEPTION_SWALLOWING);


  • I'm having the same problem as Ludek. On 64-bit Windows 10, with a 64-bit executable.

    Calling crashing code before or after .exec or crashing on a secondary thread (tested with std::async and QThread) results in the UnhandledExceptionFilter being called. If called from an event processed in the exec function the UnhandledExceptionFilter is not called.

    GetProcessUserModeExceptionPolicy and SetProcessUserModeExceptionPolicy are no longer present in kernel32.dll, so cannot experiment with them.

    Has anyone had any luck with this? Any help is much appreciated :)

  • Found a related bug here

    The issue is related to the QML JIT. As suggested setting QV4_FORCE_INTERPRETER=1 does remove the issue. We are performance heavy application so we are unable to use it.

  • Banned

    This post is deleted!

Log in to reply