diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-14 21:22:51 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-14 21:22:51 +0000 |
commit | 975c6a830c4daa5514001272e85d409c3810be89 (patch) | |
tree | 3656a66e189cc527c2ee5765054a955d0663a945 | |
parent | 9d01d29527d45e170626f03a998c3ea86264b670 (diff) | |
download | chromium_src-975c6a830c4daa5514001272e85d409c3810be89.zip chromium_src-975c6a830c4daa5514001272e85d409c3810be89.tar.gz chromium_src-975c6a830c4daa5514001272e85d409c3810be89.tar.bz2 |
[Mac] LOG(FATAL) when raising selected NSExceptions.
Exception name |NSInternalInconsistencyException| reason "Invalid
parameter not satisfying: (index >= 0) && (index < [_Itemarray
count])" is seen in many crashes, and has become more prevalent in
9.0. It appears corrlated with bug 62597. This change causes that
exception to CHECK() and generate a crash dump immediately.
BUG=24462, 62597, 62763
TEST=none
Review URL: http://codereview.chromium.org/4752007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66086 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chrome_browser_application_mac.mm | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/chrome/browser/chrome_browser_application_mac.mm b/chrome/browser/chrome_browser_application_mac.mm index b4bb7cb..c1a9b48 100644 --- a/chrome/browser/chrome_browser_application_mac.mm +++ b/chrome/browser/chrome_browser_application_mac.mm @@ -54,15 +54,38 @@ static IMP gOriginalInitIMP = NULL; } if (!found) { - // Dear reader: something you just did provoked an NSException. - // Please check your backtrace and see if you can't file a bug with - // a repro case. You should be able to safely continue past the - // NOTREACHED(), but feel free to comment it out locally if it is - // making your job hard. - DLOG(ERROR) << "Someone is preparing to raise an exception! " - << base::SysNSStringToUTF8(aName) << " *** " - << base::SysNSStringToUTF8(aReason); - NOTREACHED(); + // Update breakpad with the exception info. + static const NSString* kNSExceptionKey = @"nsexception"; + NSString* value = + [NSString stringWithFormat:@"%@ reason %@", aName, aReason]; + SetCrashKeyValue(kNSExceptionKey, value); + + // Force crash for selected exceptions to generate crash dumps. + BOOL fatal = NO; + if (aName == NSInternalInconsistencyException) { + NSString* const kNSMenuItemArrayBoundsCheck = + @"Invalid parameter not satisfying: (index >= 0) && (index < [_itemArray count])"; + if ([aReason isEqualToString:kNSMenuItemArrayBoundsCheck]) { + fatal = YES; + } + } + + // Dear reader: Something you just did provoked an NSException. + // NSException is implemented in terms of setjmp()/longjmp(), + // which does poor things when combined with C++ scoping + // (destructors are skipped). Chrome should be NSException-free, + // please check your backtrace and see if you can't file a bug + // with a repro case. + if (fatal) { + LOG(FATAL) << "Someone is trying to raise an exception! " + << base::SysNSStringToUTF8(value); + } else { + // Make sure that developers see when their code throws + // exceptions. + DLOG(ERROR) << "Someone is trying to raise an exception! " + << base::SysNSStringToUTF8(value); + NOTREACHED(); + } } // Forward to the original version. @@ -171,7 +194,7 @@ BOOL SwizzleNSExceptionInit() { } - init { - DCHECK(SwizzleNSExceptionInit()); + CHECK(SwizzleNSExceptionInit()); return [super init]; } |