Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Issue 1212093002: [Mac] Redo NSException handling, and generate better stacks for C++ exceptions. (Closed)

Created:
5 years, 5 months ago by Robert Sesek
Modified:
5 years, 5 months ago
CC:
chromium-reviews, erikwright+watch_chromium.org, sadrul
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Mac] Redo NSException handling, and generate better stacks for C++ exceptions. This introduces base::mac::CallWithEHFrame(), which will run a block in a stack frame that is set up to stop searching for an exception handler when it is reached. This is used to prevent a top-level exception handler, installed in CFRunLoopRunSpecific(), from catching and rethrowing C++ exceptions. When it does this, the resulting stack traces are not useful for triage purposes. By stoping the search for an exception handler, the runtime will call std::terminate directly from the throwing stack trace. In addition, NSException handling is converted from swizzling the designated initializer to an ObjC 2.0 exception preprocessor. Some exceptions could still escape this mechanism, if they are thrown without CallWithEHFrame() on the stack. This could happen if the exception were thrown outside of the MessagePump's work sources or -sendEvent:. Possible situations are things like the CFRunLoop block and Mach port callouts. This shouldn't happen from Chromium code, so it would only affect system-thrown exceptions. These exceptions would still be fatal, just with the less-useful run loop stack. To summarize: all uncaught exceptions are fatal one way or another. If the exception isn't caught before it unwinds to CallWithEHFrame, the crash will have an immediately actionable stack from the point of throw. If the exception is caught by the run loop or some other top-level exception handler, the exception will be rethrown and the crash stack will be less useful. In that case, if it's an ObjC exception, a crash key will still record a trace from the point-of- throw. Using try/catch is now unrestricted, and no special whitelist is maintained to allow certain NSExceptions to be alloc/init'd. BUG=503128 R=shess@chromium.org, thakis@chromium.org Committed: https://crrev.com/73dc3d5a6345ddd43a1a54f06dd4058be8a9842b Cr-Commit-Position: refs/heads/master@{#338332}

Patch Set 1 : #

Total comments: 9

Patch Set 2 : Address comments #

Patch Set 3 : Fix compile and GN #

Total comments: 6

Patch Set 4 : Align stack #

Unified diffs Side-by-side diffs Delta from patch set Stats (+374 lines, -337 lines) Patch
M base/BUILD.gn View 1 2 3 chunks +6 lines, -0 lines 0 comments Download
M base/base.gyp View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M base/base.gypi View 1 2 2 chunks +4 lines, -0 lines 0 comments Download
A base/mac/call_with_eh_frame.h View 1 chunk +26 lines, -0 lines 0 comments Download
A base/mac/call_with_eh_frame.cc View 1 chunk +37 lines, -0 lines 0 comments Download
A base/mac/call_with_eh_frame_asm.S View 1 2 3 1 chunk +89 lines, -0 lines 0 comments Download
A base/mac/call_with_eh_frame_unittest.mm View 1 chunk +53 lines, -0 lines 0 comments Download
M base/message_loop/message_pump_mac.mm View 8 chunks +29 lines, -15 lines 0 comments Download
M chrome/browser/chrome_browser_application_mac.mm View 1 2 6 chunks +129 lines, -322 lines 0 comments Download

Messages

Total messages: 29 (9 generated)
Robert Sesek
thakis: Please review. shess: Would like your review when you return from OOO. I will ...
5 years, 5 months ago (2015-06-29 17:01:42 UTC) #6
Scott Hess - ex-Googler
I _think_ LGTM, because this is high voodoo beyond my membership level. The only bit ...
5 years, 5 months ago (2015-07-06 22:34:04 UTC) #7
Robert Sesek
On 2015/07/06 22:34:04, Scott Hess wrote: > I _think_ LGTM, because this is high voodoo ...
5 years, 5 months ago (2015-07-07 22:26:17 UTC) #8
Scott Hess - ex-Googler
Still LGTM. It's plausible to me that my comment on the test is either mis-guided ...
5 years, 5 months ago (2015-07-07 22:34:31 UTC) #9
Robert Sesek
https://codereview.chromium.org/1212093002/diff/80001/base/mac/call_with_eh_frame_unittest.mm File base/mac/call_with_eh_frame_unittest.mm (right): https://codereview.chromium.org/1212093002/diff/80001/base/mac/call_with_eh_frame_unittest.mm#newcode46 base/mac/call_with_eh_frame_unittest.mm:46: ASSERT_FALSE(saw_exception); On 2015/07/07 22:34:31, Scott Hess wrote: > On ...
5 years, 5 months ago (2015-07-07 22:35:55 UTC) #10
Robert Sesek
thakis: PTAL
5 years, 5 months ago (2015-07-08 16:49:57 UTC) #12
Nico
there are no dumb questions there are no dumb questions there are no dumb questions ...
5 years, 5 months ago (2015-07-09 19:36:22 UTC) #13
Robert Sesek
On 2015/07/09 19:36:22, Nico wrote: > there are no dumb questions there are no dumb ...
5 years, 5 months ago (2015-07-09 20:16:43 UTC) #14
Scott Hess - ex-Googler
On 2015/07/09 20:16:43, Robert Sesek wrote: > On 2015/07/09 19:36:22, Nico wrote: > > there ...
5 years, 5 months ago (2015-07-09 20:21:40 UTC) #15
Nico
On 2015/07/09 20:16:43, Robert Sesek wrote: > On 2015/07/09 19:36:22, Nico wrote: > > there ...
5 years, 5 months ago (2015-07-09 20:27:48 UTC) #16
Nico
base lgtm as far as I can tell (the stack alignment comment below is because ...
5 years, 5 months ago (2015-07-09 20:43:11 UTC) #17
Robert Sesek
On 2015/07/09 20:21:40, Scott Hess (OOO 7.10-7.19) wrote: > Hey, crazy-talker here, I wonder if ...
5 years, 5 months ago (2015-07-10 16:56:09 UTC) #18
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1212093002/160001
5 years, 5 months ago (2015-07-10 17:44:31 UTC) #21
commit-bot: I haz the power
Committed patchset #4 (id:160001)
5 years, 5 months ago (2015-07-10 19:16:35 UTC) #22
commit-bot: I haz the power
Patchset 4 (id:??) landed as https://crrev.com/73dc3d5a6345ddd43a1a54f06dd4058be8a9842b Cr-Commit-Position: refs/heads/master@{#338332}
5 years, 5 months ago (2015-07-10 19:17:37 UTC) #23
Reid Kleckner
I guess this is kind of like WrappedWindowProc for Mac. Can't you just call through ...
5 years, 5 months ago (2015-07-10 19:42:36 UTC) #25
Robert Sesek
On 2015/07/10 19:42:36, Reid Kleckner wrote: > I guess this is kind of like WrappedWindowProc ...
5 years, 5 months ago (2015-07-10 19:43:50 UTC) #26
Reid Kleckner
On 2015/07/10 19:43:50, Robert Sesek wrote: > Yeah I tried noexcept too, but it basically ...
5 years, 5 months ago (2015-07-10 19:53:55 UTC) #27
Nico
On Fri, Jul 10, 2015 at 12:53 PM, <rnk@chromium.org> wrote: > On 2015/07/10 19:43:50, Robert ...
5 years, 5 months ago (2015-07-10 19:58:47 UTC) #28
chromium-reviews
5 years, 5 months ago (2015-07-10 22:59:30 UTC) #29
Message was sent while issue was closed.
On Fri, Jul 10, 2015 at 12:58 PM, Nico Weber <thakis@chromium.org> wrote:

> On Fri, Jul 10, 2015 at 12:53 PM, <rnk@chromium.org> wrote:
>
>> On 2015/07/10 19:43:50, Robert Sesek wrote:
>>
>>> Yeah I tried noexcept too, but it basically behaves like a rethrow from
>>> the
>>> function marked noexcept. See
>>> https://code.google.com/p/chromium/issues/detail?id=503128#c6.
>>>
>>
>> Hm, that's just Clang being dumb. This example gives a good stack trace
>> when
>> compiled with GCC on Linux:
>>
>
> Even with -fno-exceptions?
>

For which part of the program? I was testing with exceptions enabled for
the whole thing.

In Chromium, you'd need to arrange for the noexcept() function to have EH
enabled, and to build it with GCC. Given that GCC isn't available on Mac,
so you're probably better off just checking in an assembly file like
Robert's with an LSDA that looks like the one GCC emits. At this point,
there's not much advantage over what you've got. It just saves you from
defining your own personality. =/

To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698