Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle EXC_ARITHMETIC exception codes #2665

Open
philipphofmann opened this issue Jan 27, 2023 · 0 comments
Open

Handle EXC_ARITHMETIC exception codes #2665

philipphofmann opened this issue Jan 27, 2023 · 0 comments

Comments

@philipphofmann
Copy link
Member

Description

mach/arm/exception.h defines codes for EXC_ARITHMETIC

#define EXC_ARM_FP_UNDEFINED    0       /* Undefined Floating Point Exception */
#define EXC_ARM_FP_IO           1       /* Invalid Floating Point Operation */
#define EXC_ARM_FP_DZ           2       /* Floating Point Divide by Zero */
#define EXC_ARM_FP_OF           3       /* Floating Point Overflow */
#define EXC_ARM_FP_UF           4       /* Floating Point Underflow */
#define EXC_ARM_FP_IX           5       /* Inexact Floating Point Result */
#define EXC_ARM_FP_ID           6       /* Floating Point Denormal Input */

We use these codes to improve the generic exception message

if ([self isMathError:errorReport]) {
return @"Math error (usually caused from division by 0).";
}

We could achieve this by getting a better machCodeName here

const char *machExceptionName = sentrycrashmach_exceptionName(crash->mach.type);
const char *machCodeName = crash->mach.code == 0
? NULL
: sentrycrashmach_kernelReturnCodeName(crash->mach.code);

or here

- (BOOL)isMathError:(NSDictionary *)errorReport
{
NSDictionary *machError = [errorReport objectForKey:@SentryCrashField_Mach];
if (machError != nil) {
NSString *exceptionName = [machError objectForKey:@SentryCrashField_ExceptionName];
return [exceptionName isEqualToString:@"EXC_ARITHMETIC"];
}
NSDictionary *signal = [errorReport objectForKey:@SentryCrashField_Signal];
NSString *sigName = [signal objectForKey:@SentryCrashField_Name];
return [sigName isEqualToString:@"SIGFPE"];
}

Came up in #2662.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

4 participants