orta / ARAnalytics

Simplify your iOS/Mac analytics
MIT License
1.84k stars 217 forks source link

addEntriesFromDictionary exception and crash due to mutating dictionary #281

Open tettoffensive opened 8 years ago

tettoffensive commented 8 years ago

The properties dictionary that I'm passing in is a static dictionary (a. la. @{ ... : ... } This doesn't happen every single time.

+ (void)event:(NSString *)event withProperties:(NSDictionary *)properties
{
    NSMutableDictionary *fullProperties = [NSMutableDictionary dictionaryWithDictionary:properties];
    [fullProperties addEntriesFromDictionary:_sharedAnalytics.superProperties]; // CRASH HERE!!!

    [_sharedAnalytics iterateThroughProviders:^(ARAnalyticalProvider *provider) {
        [provider event:event withProperties:fullProperties];
    }];
}
490842621 ChannelsAppDelegate.m:45 - CRASH: *** Collection <__NSDictionaryM: 0x7f8e92e71960> was mutated while being enumerated.
490842621 ChannelsAppDelegate.m:46 - Stack Trace: (
    0   CoreFoundation                      0x000000010815ed85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000107bd2deb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010815e6e4 __NSFastEnumerationMutationHandler + 132
    3   CoreFoundation                      0x000000010807432b -[NSMutableDictionary addEntriesFromDictionary:] + 251
    4   ARAnalytics                         0x0000000102b58bf2 +[ARAnalytics event:withProperties:] + 178

    6   libdispatch.dylib                   0x0000000108e8dd9d _dispatch_call_block_and_release + 12
    7   libdispatch.dylib                   0x0000000108eae3eb _dispatch_client_callout + 8
    8   libdispatch.dylib                   0x0000000108e961ef _dispatch_main_queue_callback_4CF + 1738
    9   CoreFoundation                      0x00000001080b80f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    10  CoreFoundation                      0x0000000108079b99 __CFRunLoopRun + 2073
    11  CoreFoundation                      0x00000001080790f8 CFRunLoopRunSpecific + 488
    12  GraphicsServices                    0x000000010b025ad2 GSEventRunModal + 161
    13  UIKit                               0x000000010528df09 UIApplicationMain + 171
    14  Channels                            0x000000010224dd2f main + 175
    15  libdyld.dylib                       0x0000000108ee292d start + 1
    16  ???                                 0x0000000000000001 0x0 + 1
)
2016-07-21 18:10:20.868 Channels[49524:5890684] CFNetwork SSLHandshake failed (-9806)
2016-07-21 18:10:20.869 Channels[49524:5890037] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSDictionaryM: 0x7f8e92e71960> was mutated while being enumerated.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010815ed85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000107bd2deb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010815e6e4 __NSFastEnumerationMutationHandler + 132
    3   CoreFoundation                      0x000000010807432b -[NSMutableDictionary addEntriesFromDictionary:] + 251
    4   ARAnalytics                         0x0000000102b58bf2 +[ARAnalytics event:withProperties:] + 178
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Process 49524 resuming
BenchR267 commented 8 years ago

Hmm.. I was not able to reproduce this issue. Do you maybe have an example project? Is it possible that the main issue was not produced by ARAnalytics?

mrh-is commented 6 years ago

I also just got this crash. I have no idea how to reproduce it, since I've only seen it once, from a call site that's been called many times. Sorry I can't help with the debugging, but just recording that this has happened elsewhere!