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

[PLAT-6896] Fix NSNull handling #1143

Merged
merged 4 commits into from
Jun 30, 2021
Merged

Conversation

nickdowell
Copy link
Contributor

Goal

Fix a crash that can occur when uploading events that contain a null / NSNull stacktrace value.

NSInvalidArgumentException: -[NSNull countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x20a654a00

0  CoreFoundation          ___exceptionPreprocess
1  libobjc.A.dylib         _objc_exception_throw
2  CoreFoundation          -[NSObject(NSObject) doesNotRecognizeSelector:]
3  CoreFoundation          ____forwarding___
4  CoreFoundation          ___forwarding_prep_0___
5  Runner                  +[BugsnagError errorFromJson:] (BugsnagError.m:119:9)
6  Runner                  -[BugsnagEvent stacktraceTypes] (BugsnagEvent.m:729:31)
7  Runner                  -[BSGEventUploadOperation runWithDelegate:completionHandler:] (BSGEventUploadOperation.m:112:67)
8  Runner                  -[BSGEventUploadOperation start] (BSGEventUploadOperation.m:177:5)

See #1138

Changeset

+[BugsnagError errorFromJson:] and +[BugsnagStackframe frameFromJson:] now use the BSGDeserialize... functions to check the value types when deserializing from JSON.

BSGEventUploadOperation now encapsulates the main logic in a @try ... @catch block to prevent crashes, and reports any caught exceptions to Bugsnag using the internal error reporting mechanism.

Testing

Unit tests have been amended to verify correct handling of NSNull values.

@github-actions
Copy link

Infer: No issues found 🎉

OCLint: No issues found 🎉

Bugsnag.framework binary size increased by 1,152 bytes from 1,132,872 to 1,134,024

Generated by 🚫 Danger

@nickdowell nickdowell merged commit 4224ba8 into next Jun 30, 2021
@nickdowell nickdowell deleted the nickdowell/fix-nsnull-handling branch June 30, 2021 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants