bugfender / BugfenderSDK-iOS

Bugfender SDK for iOS, a remote logger tailor-made for mobile
https://bugfender.com
Other
76 stars 30 forks source link

Crash on empty log message #11

Closed jaroslavas closed 9 years ago

jaroslavas commented 9 years ago

If I print empty log message

DDLogVerbose(@"%@", responseObject); // responseObject = @""

Bugfender sdk crashes:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010a524f45 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000109f9edeb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010a524e7d +[NSException raise:format:] + 205
    3   Foundation                          0x0000000107d411aa +[NSString stringWithUTF8String:] + 78
    4   OneGo Testing                       0x00000001075e3ec3 __44-[BFNSLogLogger bf_processPendingLogEntries]_block_invoke_2 + 510
    5   libdispatch.dylib                   0x000000010a9b3e5d _dispatch_call_block_and_release + 12
    6   libdispatch.dylib                   0x000000010a9d449b _dispatch_client_callout + 8
    7   libdispatch.dylib                   0x000000010a9ba8ec _dispatch_queue_drain + 2215
    8   libdispatch.dylib                   0x000000010a9b9e0d _dispatch_queue_invoke + 601
    9   libdispatch.dylib                   0x000000010a9bca56 _dispatch_root_queue_drain + 1420
    10  libdispatch.dylib                   0x000000010a9bc4c5 _dispatch_worker_thread3 + 111
    11  libsystem_pthread.dylib             0x000000010ad05a9d _pthread_wqthread + 729
    12  libsystem_pthread.dylib             0x000000010ad033dd start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
jgimenez commented 9 years ago

I see you're using the DDLogVerbose macro, which is not defined in Bugfender. Are you using CocoaLumberjack?

I'm trying this test and it works for me:

- (void)testEmptyLogString
{
    id responseObject = @"";
    BFLog(@"%@", responseObject);
}

Are you sure responseObject is @"" and not nil?

jaroslavas commented 9 years ago

Yep, I'm using CocoaLumberjack. And BugFender is set up to just catch all logs: [Bugfender enableAllWithToken:@"my_token"];

jgimenez commented 9 years ago

I see. Must be something related to how CocoaLumberjack treats empty strings. Will look into it.

jgimenez commented 9 years ago

Version 0.3.16 should fix this. Please let us know if it's not working for you. Thanks for reporting.