Important: Please read the Qt Code of Conduct -

Cannot catch OS exceptions

  • In my setup I have a DLL from another company, which's source code is not in my hands. It's from a hardware vendor and uses an USB peripheral. I can use its full features, for both DLL and hardware. But there is a bug in the DLL which crashes if I run some functions while there is no hardware attached to the PC. In fact it does not crashes directly. It probably opens an USB endpoint but after an unsuccessful operation it tries to execute an invalid operation on that object while trying to unload the DLL.

    Since I don't have access to the source of DLL, I can not fix this bug directly. So I should be handling it in my own code. I was doing the same with try/catch using .NET but as far as I can see it's not so easy with Qt.

    How can I catch an exception thrown by OS (or from another subsystem) which can not be caught with usual "catch(...)".

    OS: Win8
    Compiler: MSVC 11.0 & MinGW 4.8.2

  • Using Try Catch of c++?

  • Yes. I'm using C++ try/catch but unable to catch it.

    Here's the MSVC exception message under debug.

    bq. The inferior stopped because it triggered an exception.
    Stopped in thread 0 by: Exception at 0x3dc2cbea, code: 0xc0000008: , flags=0x0 (first chance).

    MinGW provides even less information.

    bq. The inferior stopped because it received a signal from the Operating System.
    Signal name : ?
    Signal meaning : Unknown signal

  • Hardware exceptions do not come through C++ try/catch
    You may try to use "segvcatch library":
    It converts hardware exceptions into c++ exceptions.

  • Thanks andreyc. But looks like this project is not maintained and has issues. Even if it works, it wouldn't help to this problem.

    There is also a similar project called "libsigsegv": and it tries to solve similar exceptions in *nix OSes. But again, no luck with my problem.

    Thanks again.

Log in to reply