bugsnag / bugsnag-cocoa

BugSnag error monitoring & exception reporter for iOS, macOS, tvOS and watchOS
https://docs.bugsnag.com/platforms/ios
MIT License
238 stars 130 forks source link

fatalError message not captured by BugSnag #1679

Open 0xpablo opened 4 months ago

0xpablo commented 4 months ago

Describe the bug

Hi there, we are in the process of evaluating BugSnag to switch from Crashlytics. We use GRDB and sometimes have fatalConversionError crashes. This crash happens when there is an attempt to read a value from a missing column for instance. I noticed that Crashlytics populates a crash_info_entry_0 key with data such as this:

/Users/distiller/Library/Developer/Xcode/DerivedData/xxx-gkoktxxwoccurtcsovqddkqarggu/SourcePackages/checkouts/GRDB.swift/GRDB/Core/DatabaseValueConversion.swift:160: Fatal error: could not read Bool from missing column `feature_enabled` (row: [id:"xxx" parent_folder_id:"yyy" lww_parent_folder_id:Data(48 bytes) root_folder_id:"zzz" item_id:"..., sql: `SELECT folder_to_folder_items.*, CASE documents.document_type WHEN 0 THEN pages.thumbnail_tag WHEN 1 THEN problems.thumbnail_tag

I checked GRDB's source and it's using a fatalError with a dynamic message:

func fatalConversionError<T>(
    to: T.Type,
    from dbValue: DatabaseValue?,
    conversionContext: ValueConversionContext?,
    file: StaticString = #file,
    line: UInt = #line)
    -> Never
{
    fatalError(
        conversionErrorMessage(
            to: T.self,
            from: dbValue,
            conversionContext: conversionContext),
        file: file,
        line: line)
}

We can't see the error message in BugSnag

image image

I noticed there was this old PR fixing fatalError reporting https://github.com/bugsnag/bugsnag-cocoa/pull/948 and https://github.com/bugsnag/bugsnag-cocoa/pull/1010 I'm wondering if something's changed in the swift runtime that might have broken this.

Environment

clr182 commented 4 months ago

Hi @0xpablo

Thank you for bringing this to our attention.

Although we were previously able to capture this message, it does appear that it is only available in debug builds using our current mechanism. We'll need to investigate this issue further to determine whether the message is available elsewhere in a location that we can access at crash time.

Can you confirm if you were previously seeing the message in Crashlytics, even in a release build?

0xpablo commented 4 months ago

Hi @0xpablo

Thank you for bringing this to our attention.

Although we were previously able to capture this message, it does appear that it is only available in debug builds using our current mechanism. We'll need to investigate this issue further to determine whether the message is available elsewhere in a location that we can access at crash time.

Can you confirm if you were previously seeing the message in Crashlytics, even in a release build?

Hi @clr182, yes, this is accessible in Crashlytics on release builds. AFAIK we don't have any specific config, and we haven't changed any build config when switching from Crashlytics to BugSnag. This thread might be relevant: https://github.com/getsentry/sentry-cocoa/issues/662

clr182 commented 4 months ago

Hi @0xpablo

Thank you for sharing.

We do have an item on our backlog aimed at investigating this issue further. However I should mention that this is not a trivial fix. As such I do not currently have a timeframe for this issue, however we will be sure to update you via this ticket thread once we have more information to share.