-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
Fix SDK crash in encodeObject #4424
Comments
We now also this in |
I was looking at the errors, and they change between two places: here
and here
Two places that need to allocate more memory. I don’t think the size of the information is the issue; I believe the device is already running out of memory. I’ve attempted to send large content, such as a 10MB text as scope tag value, which we don’t even support sending. However, there’s no way to break the encoding as long as there’s available memory. I tried to stress test scope serialization with all kinds of crazy things and nothing. I don’t think we should preemptively truncate strings to an arbitrary length when we don’t have any buffer restrictions. |
Description
The SDK sometimes crashes with. See also internal SDK crashes for reference. This is our most frequent SDK crash in our latest stable release 8.36.0.
The culprit is here
sentry-cocoa/Sources/SentryCrash/Recording/Tools/SentryCrashJSONCodecObjC.m
Lines 318 to 332 in eae2b59
Looking at the stacktrace, it seems like we can't allocate enough memory to encode the NSString to NSData. As this code is called from the scope observer, this could happen if some of our users try to put a very large string to the scope. We could fix this by truncating long strings in the scope.
I also noticed that we could use
dataUsingEncoding
with settingallowLossyConversion:YES
so the conversation looses some data such as ‘Á’ becomes ‘A’ instead of throwing the whole string away, but that isn't related to the crash.The text was updated successfully, but these errors were encountered: