PDA

View Full Version : How to catch "access violation" exception in QT?



vrushalid
23rd April 2012, 11:29
Hi All,

We have built an application in QT which internally uses third party libraries like boost. We want to catch the exceptions throw which are thrown by these libraries e.g "acess violation" [0xC0000005: Access violation reading location 0x00000004.] exception.

But these exceptions are not catched in "catch(std::exception& e)" or "catch(...)" :(.

Please let me know how to catch such exceptions in QT.

Thanks in advance,
Vrushali

wysota
23rd April 2012, 12:03
Qt doesn't deal with things like that. Use mechanisms provided by the programming language you are using.

ChrisW67
23rd April 2012, 19:28
Please let me know how to catch such exceptions in QT.
Qt has nothing to do with exception handling: that's between you and your programming language.

The exception you have is the result of using a null/invalid pointer or possibly an undefined reference. Such exceptions are not recoverable: they are fundamental flaws in your program logic not exceptions to normal program flow. You "catch" these exceptions using your debugger to identify the offending pointer from the stack backtrace, locate the logic error in your program, and repair your code.

wysota
24th April 2012, 00:06
Technically you can catch those as well (e.g. by intercepting SIGSEGV) however rarely there is a point in doing so (apart dumping a backtrace to the log and cleaning up before aborting to prevent a nuclear meltdown if your app happens to operate a nuclear power plant).