-
Notifications
You must be signed in to change notification settings - Fork 57
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
Getting crashes on DataTransferObject since updating #245
Comments
@mfernandez94 , are you using any custom settings for the server data in your RollbarConfig object? If yes, can you post a code snippet (of what and how you set it) here? |
@akornich I don't believe so, but we are setting this on init of rollbar, is this what you mean? |
@mfernandez94 , yes, that is what i wanted to see. thanks! A Foundation object that may be converted to JSON must have the following properties: |
@akornich Ok, thank you! I added some valid JSON checks, and I'll update if the issue is resolved |
@mfernandez94 , do you have any update on the issue? can we close it? |
@akornich So just created a fix for it checking if the data is valid before sending, and seems like we are still getting the crash issue |
@mfernandez94 , can you, please, confirm - these crashes happen only on some of the payload instances and not on all, correct? |
@akornich yes only on some, also it seems like they have stopped crashing on the ones with data (for the most part), and according to the crash logs they happen mostly on log ErrorWithMessage without any data attached just the message |
Bump. This causing a lot of crashes for us. |
@eb-smith-affirm , what version of the SDK are you using? Also, could you, please, post here the trace stack of the crash? |
@akornich I would like to follow up on this since we still experiencing the issue. The crashes are not consistent and happen in a few different places. The first one is in the DataTransferObject.m
The next two crashes happen when we try to call
RollbarPayload.m
And another one is in NSJSONSerialization+Rollbar.m
Unfortunately, I couldn't reproduce any of them but they all seem related. My guess is that we are passing nil at some stage, but I see no traces of that. Any hints about how to pinpoint this issue would be very helpful. Our Rollbar version is |
@okalentiev, thanks a lot for the provided traces! While I can not see any obvious cause for the exceptions by looking at the traces briefly, I'll spend some time in a few days experimenting with the code along the paths outlined here... |
@okalentiev , btw, could it be that when you make some Rollbar logging calls while providing the custom data dictionary parameter, some of the dictionary values happen to be nils? I don't think we are gating or clearing such values from the custom data dictionary at the moment. Any nil value would break the JSON serialization. You have to either make sure key-values that have nil as a value are all removed from the data dictionary, or use NSNull instead of the nils. |
@akornich Thanks for the swift response and clarification! The last two crashes were happening from log calls without a custom data dictionary. But I just checked and in certain cases, we have nil values in RollbarConfiguration's Shall we close this one or you want me to get back to you once the fix is released on our side? |
@okalentiev , thanks for the update, much appreciated! Let's close it after you confirm that fixing nils in customData resolves all the crashes. |
@akornich I saw this crash in a different app, and have put together a sample app to help you guys reproduce the race condition. Just create a fresh empty app and use the following app delegate code (updating access token accordingly):
Note that it's a race condition, so may not hit every single time, but it's pretty close for me. |
@keagan , thanks a lot for the repro and the screenshot! i think it is never a good idea to keep modifying a collection (dictionary) while iterating through it. i'll plan to fix it on Monday and have a new alpha release right away. |
@keagan , i take it back. there is nothing wrong with iterating a dictionary via keys while removing some elements from the dictionary. it looks like something else messes up the memory. i am looking into it... |
@keagan, I think I narrowed down to what could be causing crashes in your test scenario. Our current use of RollbarConfig structure within the shared instance of RollbarLogger is not thread-safe at the moment. Until we properly fix it (which is a significant effort), we would recommend the following workaround: For example, somewhere closer to the startup of the main application/process thread, initialize the shared instance of Rollbar: [Rollbar initWithAccessToken:@"NNNN"];
Rollbar.currentConfiguration.destination.accessToken = @"NNNN";
Rollbar.currentConfiguration.destination.environment = @"unit-tests";
Rollbar.currentConfiguration.developerOptions.transmit = YES;
Rollbar.currentConfiguration.developerOptions.logPayload = YES;
Rollbar.currentConfiguration.loggingOptions.maximumReportsPerMinute = 5000;
Rollbar.currentConfiguration.telemetry.enabled = YES;
Rollbar.currentConfiguration.loggingOptions.captureIp = RollbarCaptureIpType_Full;
//etc... You can use However, later for every new thread use a dedicated RollbarLogger instance, configured either fully or partially based on the shared instance configuration, to do the work: for( int i = 0; i < 20; i++) {
dispatch_async(dispatch_get_global_queue(QOS_CLASS_UTILITY,0), ^(){
RollbarLogger *logger = [[RollbarLogger alloc] initWithAccessToken:Rollbar.currentConfiguration.destination.accessToken];
for (int j = 0; j < 20; j++) {
[logger log:RollbarLevel_Error
message:@"error"
data:nil
context:[NSString stringWithFormat:@"%d-%d", i, j]
];
//DO NOT USE THE SHARED INSTANCE: [Rollbar errorMessage:@"error"];
}
});
} |
got it, @akornich. we'll look into it and follow your guidance, thanks. |
@akornich Thanks a lot for the provided steps! Can you please clarify what is the |
@okalentiev, sorry for the confusion. You are absolutely correct! I based my code snippet on our v2-alpha codebase of the SDK where RollbarNotifier was renamed into RollbarLogger. |
@keagan , i just wanted to check with you if my recommendation worked for you... |
closing it. if anyone experiences this type of issue - feel free to reopen it. |
Started to see a rise in crashes for users since updating, stack trace seems to show its an issue in
[DataTransferObject(Protected) initWithDictionary:] + 41
and
-[DataTransferObject initWithDictionary:] + 335
side note I noticed we were getting crashes when sending a URL type in the data dictionary, so transformed them into strings, but still getting a good amount of crashes. Could it be possible other invalid JSON is getting through? Insights say heap corruption but not sure if that's the case.
The text was updated successfully, but these errors were encountered: