AbdFatah / analytics-issues

Automatically exported from code.google.com/p/analytics-issues
0 stars 0 forks source link

iOS SDK Crash in percentEncode: with certain bad error strings #284

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
---------------------------------------------------------------------------
NOTE: This issue tracking system is for Google Analytics developer products
only.
If you are not a developer/programmer visit:
http://www.google.com/analytics/support.html
---------------------------------------------------------------------------
Name of affected component: Mobile Tracking

Name of related library and version, if applicable (e.g. Android, iOS,
Snippets, etc.): iOS v2.0 beta 4

Issue summary:
Occasionally, an error string passed to [[GAI sharedInstance].defaultTracker 
sendException:withDescription:] will lead to a crash in the internal method 
+[[GAIStringUtil percentEncode:]

Steps to reproduce issue:
1. Not easily reproducible. Passing nil, @"", or special characters to 
sendException: does not yield the problem.
2.
3.

Expected output:
No crash

Actual results:
Crash

Incident Identifier: A46D0163-15DD-4EEC-A1D0-508CD9DC77F9
CrashReporter Key:   ce403b5564b8082ae5edb04d87093ee833bfef3b
Hardware Model:      iPhone5,1
Process:         CB30 [11311]
Path:            
/var/mobile/Applications/5FA940F2-0EA6-4F4F-8599-FAB49DCC218F/CB30.app/CB30
Identifier:      CB30
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2013-04-01 14:34:23.252 -0400
OS Version:      iOS 6.1.2 (10B146)
Report Version:  104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000000000defe
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   CoreFoundation                  0x32ddb68a CFRelease + 18
1   CB30                            0x004dff8e +[GAIStringUtil percentEncode:] 
(GAIStringUtil.m:95)
2   CB30                            0x004dcdaa -[GAIRequestBuilder 
encodeParameter:withValue:] (GAIRequestBuilder.m:52)
3   CB30                            0x004dcfac -[GAIRequestBuilder 
encodeParameters:] (GAIRequestBuilder.m:67)
4   CB30                            0x004dd0e2 -[GAIRequestBuilder 
requestForHit:] (GAIRequestBuilder.m:77)
5   CB30                            0x004e72ae -[GAIDispatcher 
initiateDispatch:retryNumber:] (GAIDispatcher.m:484)
6   CB30                            0x004e4cf4 __25-[GAIDispatcher 
dispatch]_block_invoke_0 (GAIDispatcher.m:174)
7   libdispatch.dylib               0x3afa5790 _dispatch_call_block_and_release 
+ 8
8   libdispatch.dylib               0x3afa55d8 _dispatch_client_callout + 20
9   libdispatch.dylib               0x3afa8e40 _dispatch_main_queue_callback_4CF 
+ 224
10  CoreFoundation                  0x32e6e1ac __CFRunLoopRun + 1284
11  CoreFoundation                  0x32de1238 CFRunLoopRunSpecific + 352
12  CoreFoundation                  0x32de10c4 CFRunLoopRunInMode + 100
13  GraphicsServices                0x369bf336 GSEventRunModal + 70
14  UIKit                           0x34cfd2b4 UIApplicationMain + 1116
15  CB30                            0x000c61ce main (main.m:16)
16  CB30                            0x000c6184 start + 36

Notes:
Although [GAIStringUtil percentEncode:] is a private method, using 
NSClassFromString and performSelector: I was able to test various values thrown 
at that method directly. I found that passing nil to that method yields the 
exact same stack trace as above. So, I tried a solution using method swizzling 
where I intercepted all calls to percentEncode: and only allowed non-nil 
parameters to proceed and be encoded. If I got a nil, I would just return an 
empty string. However, some time later, this same crash reappeared even with my 
interception method. Unfortunately the tester could not get their device back 
into this state for further analysis, but the conclusion is that some other 
value besides nil is causing percentEncode: to bomb. And when you get into this 
situation, it totally prevents your app from launching (assuming you 
instantiate GAI upon app load) - which is obviously a non-starter.

Original issue reported on code.google.com by danny.pa...@dublabs.com on 9 Apr 2013 at 7:49

GoogleCodeExporter commented 9 years ago
I'm experiencing the same thing and can recreate it easily.  I will post a 
sample project in the next couple days.

Original comment by jpsw...@gmail.com on 6 Nov 2013 at 12:24

GoogleCodeExporter commented 9 years ago

Original comment by awa...@google.com on 7 Nov 2013 at 9:52

GoogleCodeExporter commented 9 years ago
We'll take a look into this, it would be a big help for us if you could provide 
a sample project or steps to reproduce.

Original comment by awa...@google.com on 8 Nov 2013 at 9:11

GoogleCodeExporter commented 9 years ago
As I mentioned in my original post, I could not find a consistent repro but the 
error is always that somehow a nil value ends up being passed to 
+[GAIStringUtil percentEncode:]. I think eliminating this crash would be as 
easy as putting a check in that function to handle nil

Original comment by danny.pa...@gmail.com on 10 Nov 2013 at 4:52

GoogleCodeExporter commented 9 years ago
Here's my sample project:
https://github.com/jpswain/HLGACrashExample
(for some reason i got an error every time trying to upload)

I ran it with an iPhone 5S on 7.0.4.  The SDK used was 7.0, with Xcode 5.0.1.  
GA version is 2.0b4.

To recreate:
1) run application attached to debugger.
2) watch time, you will see it change to queued=YES at 5 seconds.
3) at ≈25.1 you will crash.
4) try relaunch, either on debugger or just tap the icon on the device, it will 
crash every time, even though the sending of exceptions only happens the first 
time.

Hope this helps!
Let me know if any questions,

Jamie

Original comment by jpsw...@gmail.com on 24 Nov 2013 at 12:44

GoogleCodeExporter commented 9 years ago
Please migrate to v3. See the migration guide:
https://developers.google.com/analytics/devguides/collection/ios/v3/migration

Original comment by pfrise...@google.com on 24 Oct 2014 at 7:19