Open Bug 1579688 Opened 5 years ago Updated 2 years ago

Is it possible to get the exception message from CrashReporter::TerminateHandler()?

Categories

(Toolkit :: Crash Reporting, enhancement)

enhancement

Tracking

()

People

(Reporter: mstange, Unassigned)

References

Details

Bug 1579431 has crashes of this form:

0 XUL CrashReporter::TerminateHandler toolkit/crashreporter/nsExceptionHandler.cpp:1457
1 libc++abi.dylib std::__terminate 
2 libc++abi.dylib __cxa_rethrow 
3 libobjc.A.dylib _objc_rootTryRetain 
4 AppKit -[NSView _sendViewWillDrawAndRecurse:] 
5 AppKit -[NSView _layoutSublayersOfLayer:] 

I'm not sure who's rethrowing what kind of exception here. Is there a handler in _objc_rootTryRetain that catches and rethrows exceptions? Are those exceptions Objective C NSExceptions or C++ exceptions? Or could it maybe be either and we don't know?
And is there any way we could get at an error message? It would be useful to know why an exception is thrown here.

This is happening inside C++'s termination handler which is rather platform-specific and I don't know how it handles exceptions coming from Objective-C[++] code. I suppose we might try inspecting std::current_exception and see what gives.

I've dug into this a bit further. The "standard" way to inspect the exception held in std::current_exception is to rethrow it, catch it in a catch clause catching every possible exception and inspecting said exception using std::exception::what() for example. This example code demonstrates how this works. However I don't know how that interacts with Objective-C[++] exceptions and if we can put a functioning catch block in our code. This will need a bit of experimentation.

I just discovered NSSetUncaughtExceptionHandler(). I wonder if it's possible to use it to catch Objective-C exceptions before they get into std::terminate_handler. We would have access to the NSException so we could pull out some useful information such as the name and reason.

Depends on: 1693434
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.