ios send: crashes if we have used setUserCustomData

Dan Too

Posted on
Apr 16 2015

If I have used [[Raygun sharedReporter] setUserCustomData:someDictionary]; then when I do a manual [[Raygun sharedReporter] send: I get a crash.

I can prevent this by setting the userCustomData to nil before a send: but a crash in the Raygun Reporter isn't desirable.

Let me know if you need any more detail


Jason Fauchelle

Raygun

Posted on
Apr 16 2015

Hi Dan,

Please send repro example of the dictionary you are setting. Keep in mind that it should only contain simple data such as strings and numbers.

Also, let me know which send method you are calling along with any parameters.

Any information you have about the crash would be helpful too.

-Jason Fauchelle


Dan Too

Posted on
Apr 16 2015

Hey Jason,

Here's a sample project for you, you'll just need to set an API key

https://github.com/regennz/raygunCrash/tree/customUserInfo

All I'm doing is:

[[Raygun sharedReporter] setUserCustomData:@{@"test":@"value"}];
[[Raygun sharedReporter] send:[NSException exceptionWithName:@"TEST EXCEPTION NAME" reason:@"TEST REASON" userInfo:nil] withTags:nil withUserCustomData:nil];

Jason Fauchelle

Raygun

Posted on
Apr 18 2015

Hi Dan,

Thanks for the sample and code, I've been able to reproduce the problem now.

It seems that initializing the dictionary as a local variable, rather than inlining it in the property setter allows this to work as expected:

NSDictionary *data = @{@"test":@"value"};
[[Raygun sharedReporter] setUserCustomData:data];

I am yet to find if this is expected behaviour of Objective-C, or if there is an issue in the Raygun4iOS provider. When writing it all in one line, seems the dictionary is being deallocated some time before the provider accesses it to send it in the report. I'll let you know what I find.

-Jason Fauchelle


Rob

Posted on
Apr 18 2015

Hi, I've just run into a similar issue for NSErrors with Xcode 6, building for iOS 8.1+. Using Raygun lib 1.6.0 included with Cocoapods 0.34.4 with default settings. This is the first time we've attempted to manually send errors and/or exceptions. All other raygun functions have been working as expected for months.

This invocation seems to crash the simulator or app immediately:

  [[Raygun sharedReporter] sendError:someError withTags:nil withUserCustomData:nil];

I've tried both having userCustomData set at app launch, or nil. Have tried locally creating NSErrors or handling ones which bubble up from elsewhere. So far have not been able to get an NSError delivered to Raygun.

Any suggestions or help would be appreciated!


Jason Fauchelle

Raygun

Posted on
May 06 2015

Dan,

Does my suggestion work for you? (Setting the dictionary literal to a pointer variable, and then passing that pointer to the property setter). Unfortunately I have not found any solid information as to why this would break when inlining the literal in the property setter. Every single example I have found happens to be setting the dictionary literal to a pointer before using it. I have further experimented with changing Raygun4iOS, but everything I've tried results in the same behavior. I'll keep this on my backlog to try again in the future.

Rob,

Sorry, I have not been able to reproduce this issue. This code works fine for me to send an NSError:

NSString *fileToLoad = @"/path/to/non-existent-file.txt";
NSError *error;
NSString *content = [NSString stringWithContentsOfFile:fileToLoad encoding:NSUTF8StringEncoding error:&error];

[[Raygun sharedReporter] sendError:error withTags:nil withUserCustomData:nil];

Does that work for you? If you still have trouble here, please send more information that may help reproduce this problem, or send a simple repro project, and I'll look into it for you.

-Jason Fauchelle


Sam

Posted on
May 14 2015

I can confirm the above suggestion does not work. We're encountering the same issue.


Sam

Posted on
May 14 2015

We've, however, resolved this by storing it statically. Which is consistent with the diagnosis above.


Dan Too

Posted on
May 14 2015

Sorry guys, forgot to reply to this.

I actually discovered this bug in a scenario where it was initialised on a separate line, not inlined, so I don't think that's the actual bug in this case.

As mentioned before, I resolved it in my project by nilling out the userCustomData before any manual send.


Rob

Posted on
May 15 2015

Thanks Jason, yes still having issues reporting NSErrors. I'll try to create a small project replicating our set up. We use Bolts framework significantly so error capturing and posting to your API occurs across different GCD queues. Will post something over next few days. Cheers


Jason Fauchelle

Raygun

Posted on
May 18 2015

Thanks Rob, a repro project will be a great help to solving this.

Dan, if you are able to modify your previous repro project in a way that causes the crash when the dictionary is created on a separate line, I will look into it further.

-Jason Fauchelle


Rob

Posted on
Jun 02 2015

Hi Jason,

I've attached a sample project which reproduces the issue when trying to report an NSError.

We appear not to be able to use .userCustomData when programmatically delivering NSErrors to Raygun.

Setting the userCustomData to nil just before posting the error isn't a good workaround, as this metadata is then lost should an actual crash occur thereafter. Plus we lose the useful identifying information to help us resolve the issue.

Hope you can nail this one soon.


Jason Fauchelle

Raygun

Posted on
Jun 04 2015

Hi Rob,

Thanks for the repro project. I can reproduce the issue now and looking for a solution. I'll get back to you tomorrow with what I find.

-Jason Fauchelle


Jason Fauchelle

Raygun

Posted on
Jun 05 2015

Hi Rob,

Sorry, I was not able to look into this further today. I will get back to you next week.

-Jason Fauchelle


Rob

Posted on
Jun 08 2015

Hey Jason,

Thanks, keep us posted! We're planning to use this initially in the way the example shows. (Namely core data validation-on-save errors). Looking forward to it working soon.


Jason Fauchelle

Raygun

Posted on
Jun 12 2015

Hi Rob,

I have solved this issue which will be fixed in the next version. This will be released next week. Thanks again for the repro project, I'll let you know when the fixed version is published.

-Jason Fauchelle


Rob

Posted on
Jun 12 2015

Thanks Jason,

Great news. Looking forward to the update.


Jason Fauchelle

Raygun

Posted on
Jun 19 2015

Hi Rob,

The next version of Raygun4iOS (v2.1.0) containing the userCustomData property fix has just been published. This is available via CocoaPods, or download the framework here: https://s3.amazonaws.com/data.raygun.io/providers/raygun4ios/2.1.0.zip

-Jason Fauchelle


Rob

Posted on
Jun 26 2015

Hey Jason, Works a charm. Thanks for fixing this up! Rob


Dan Too

Posted on
Jun 26 2015

Agreed. So far so good from me also, thanks!


Jason Fauchelle

Raygun

Posted on
Jun 26 2015

Excellent, no worries!


Reply