Skip to content

Handle EXC_ARITHMETIC exception codes #2665

@philipphofmann

Description

@philipphofmann

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions