-
-
Notifications
You must be signed in to change notification settings - Fork 330
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
Crash during SDK initialization, presumably due to corrupted envelope data from a previous run #4280
Comments
Update: I was able to reliably reproduce the crash by e.g. putting the following envelope file in my Sentry SDK's "envelopes" directory:
Note how there is no attachment after the The triggered exception is |
I have since received a second report from another user of the same crash. This is particularly bad because I can't even tell how many users are affected in total specifically because it happens before the Sentry SDK has been fully initialized, so no crash reports get sent whatsoever. |
@MrMage thank you for the detailed report, we'll investigate this shortly |
Thanks for the quick reply! FYI, I have confirmed that the following two extra if (i > data.length) {
// The following read would be out of bounds; for a well-formed envelope, this would not happen, but we
// still guard against it to avoid a crash in case of a corrupted envelope.
break;
}
NSData *itemHeaderData =
[data subdataWithRange:NSMakeRange(itemHeaderStart, i - itemHeaderStart)]; if (i + 1 + bodyLength > data.length) {
// The following read would be out of bounds; for a well-formed envelope, this would not happen, but we
// still guard against it to avoid a crash in case of a corrupted envelope.
break;
}
NSData *itemBody = [data subdataWithRange:NSMakeRange(i + 1, bodyLength)]; However, these do not contain any (Also, I just noticed that the code I inserted uses tabs instead of spaces; sorry about that 😅) |
#4281 could fix one part of the problem, but we have to investigate further what could cause this problem. |
We are getting similar reports from multiple users:
|
It happened after I upgraded from So now I went back to Platform: iOS, React Native. App Wrapped in |
@dylancom thank you for the quick reply and confirming the versions. The most probable cause is that sentry-cocoa 8.33.0 created the invalid envelope, versions of 8.34.0+ include a fix for the crash, and 8.35.0+ include the fix for the envelopes. We will ship a release of |
@kahest, did you consider making your guard against the crash more defensive, as I suggested in #4280 (comment)? Currently, the code is checking for an envelope missing altogether, but not for a partially-written envelope. Would it make sense to also check for partially-written envelopes (i.e. |
Thank you! I agree that the fix is most likely effective under nearly all circumstances, but given that the impact of the issue when it occurs is fairly catastrophic (a crash without any crash reporting), I appreciate the additional safeguards, just in case. |
Closing this now. The crash and root cause are fixed in 8.35.0+. Further work on reducing memory footprint during envelope serialization is tracked in #3630. |
Sentry found a crash in their SDK initialisation process: getsentry/sentry-cocoa#4280 It’s difficult to assess the impact, as we don’t have the benefit of any Sentry issues for these crashes. We believe at least 12 devices have been affected in the last 2 weeks. This commit updates us to the latest version, which has the fix for the crash.
Platform
macOS
Environment
Production
Installed
CocoaPods
Version
8.33.0
Xcode Version
15.2
Did it work on previous versions?
No response
Steps to Reproduce
No repeatable reproduction steps just yet, but I hope that inspecting the code around
SentrySerialization.m:225
is sufficient to guard against this issue in the future.Expected Result
No crash, even when trying to process corrupted envelopes.
Actual Result
I have received a report of my app crashing at launch from a user. No reports of this crash could be found in Sentry, however.
Manual inspection of the crash report revealed the reason for that: The crash appears to be caused by a crash in Sentry itself while it attempts to send cached envelopes, possibly for a previous crash. My suspicion is that the previous envelope is corrupted, and the code responsible for sending the cached envelopes is not prepared for that.
I can't share a full crash report at this time (it wouldn't be very useful without my debug symbols), anyway. However, I have manually desymbolicated the stack trace, and the following call sites are involved:
SentrySerialization.m:225
isNSData *itemBody = [data subdataWithRange:NSMakeRange(i + 1, bodyLength)];
. My suspicion is that this line is called with invalid values, causing an out-of-bounds exception. As the SDK is still in its own startup phase, it can not catch the resulting exception nor upload a crash report for itself.Are you willing to submit a PR?
No, but see my suggestion for a fix below.
The text was updated successfully, but these errors were encountered: