6

I'm getting a crash that, to me, seems as though it is a bug in the way that Apple is handling the goToDefaultLocation message of MKMapView. That message in turn calls [ALCityManager localeWithCode:], which calls [NSLocale componentsFromLocaleIdentifier:] which calls CFLocaleCreateComponentsFromLocaleIdentifier which calls CFStringGetLength and the crash occurs.

Can someone help to point me in the direction of either fixing the bug, if it is my code that is causing this, or, helping me find a workaround if, in fact, this is a bug in Apple's code (unlikely??).

Crash log below:


Incident Identifier: 84198BB6-45BD-493B-955F-75CCB5246DDD
CrashReporter Key:   7dbf53bf1f1a3635d7c3c49e726dedc609ed9f3a
Hardware Model:      iPhone3,1
Process:         MyApp [340]
Path:            /var/mobile/Applications/DCE9A5A1-8E24-4D4F-A1ED-9855C6CA1742/MyApp.app/MyApp
Identifier:      MyApp
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2011-03-25 10:36:06.382 -0700
OS Version:      iPhone OS 4.3 (8F190)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   CoreFoundation                  0x00009a66 CFStringGetLength + 6
1   CoreFoundation                  0x0002f994 CFLocaleCreateComponentsFromLocaleIdentifier + 60
2   CoreFoundation                  0x000483b8 +[NSLocale componentsFromLocaleIdentifier:] + 12
3   AppSupport                      0x00016eee -[ALCityManager localeWithCode:] + 130
4   MapKit                          0x00038488 -[MKMapView goToDefaultLocation] + 80
5   Foundation                      0x000907c6 __NSFireTimer + 130
6   CoreFoundation                  0x00075a40 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
7   CoreFoundation                  0x00077ec4 __CFRunLoopDoTimer + 844
8   CoreFoundation                  0x0007883e __CFRunLoopRun + 1082
9   CoreFoundation                  0x00008ebc CFRunLoopRunSpecific + 224
10  CoreFoundation                  0x00008dc4 CFRunLoopRunInMode + 52
11  GraphicsServices                0x00004418 GSEventRunModal + 108
12  GraphicsServices                0x000044c4 GSEventRun + 56
13  UIKit                           0x0002ed62 -[UIApplication _run] + 398
14  UIKit                           0x0002c800 UIApplicationMain + 664
15  MyApp                               0x000023f0 main (main.m:34)
16  MyApp                               0x00002370 start + 44
Vincent Guerci
  • 14,379
  • 4
  • 50
  • 56
fatfreddyscat
  • 835
  • 3
  • 8
  • 26
  • 1
    It's hard to know if there's a bug in your code unless you post your code. goToDefaultLocation isn't a documented public method of MKMapView. What are you actually doing in your code when this crash occurs? – CharlieMezak Apr 13 '11 at 00:27
  • Nothing -> the crash occurs at startup. – fatfreddyscat Apr 13 '11 at 23:08

2 Answers2

2

I got exactly the same crash reports, ONLY with iOS 4.3 / 4.3.1 AND iPhone 3GS/4 (armv7)

I think it is an Apple Bug, iOS4.3 has others ugly regressions concerning MapKit. (like the MKReverseGeocoder early releasing crash...)

  1. An easy workaround would be to override -[MKMapView goToDefaultLocation] but at the risk of an Apple rejection since it is a private API... (Rejected for a bug workaround... I know... People are mean)

  2. Another solution would be to analyze (reverse...) CFLocaleCreateComponentsFromLocaleIdentifier and componentsFromLocaleIdentifier: and [ALCityManager localeWithCode:] to understand how it can crash, being called with a nil locale identifier and maybe fix application locale programmatically, since it looks like the error coming from determining user's locale from device settings (or worse, from city/geolocation)... or at least WARN user that its locale settings might cause troubles... Something I just can not(/want to) do, not being able to reproduce that bug.

Vincent Guerci
  • 14,379
  • 4
  • 50
  • 56
  • thanks! this is along the lines of what I am thinking too. *luckily*, our customer that is seeing the crash is going to come into the office with his device - hopefully I can fix/solve it with the crashing device in hand and then comment as to the fix (err, likely, workaround). – fatfreddyscat Apr 14 '11 at 16:57
  • glad to hear that, make sure to 1. check its locale at runtime, probably `- [NSLocale currentLocale]` 2. try with gdb to `fb -[ALCityManager localeWithCode:]` and its *friends* in stacktrace to breakpoint **before** the crash and analyze registers and such... Maybe a step by step if you can read some arm assembly code... I hope you'll find a fix and share your experience! – Vincent Guerci Apr 14 '11 at 22:24
  • Sorry for forgetting to update this. You were right, Vincent and after a couple back and forths with Apple support, it is, indeed, an Apple issue. Thanks so much for your help! – fatfreddyscat May 03 '11 at 07:25
  • 1
    P.S. The workaround is to set the locale to something other than En then, set it back. FYI. Waiting on a fix. – fatfreddyscat May 03 '11 at 07:26
  • @fatfreddyscat thanks a lot for your feedback, that *might* help. (I don't see how I could detect this and warn users), how did you get that information from Apple? just submitting a bugreport? – Vincent Guerci May 03 '11 at 08:28
  • No -> I contacted their technical support and had a few back-and-forth emails. – fatfreddyscat May 05 '11 at 17:24
  • 1
    P.S. I don't know about "detecting" it. It only occurred very rarely. If you get anyone reporting strange crash at startup, then, post a disclaimer referencing the known Apple crash and direct them to go to their Settings->General->International->Region Format and set it to something other than 'United States' and set it back. – fatfreddyscat May 05 '11 at 17:27
  • I see, no easy workaround, no way to detect / prevent bug easily... only few people concerned... okay... i don't like this but then let's just wait for a new iOS version!... thanks again for your replies. – Vincent Guerci May 05 '11 at 20:40
  • =-) I just hope that my findings might help someone as this was quite the pain. – fatfreddyscat May 11 '11 at 22:05
  • Thanks Vincent, It helped me a ton, now my app works like a charm :) – Richard J. Ross III Sep 14 '11 at 17:30
  • @Richard J. Ross III what solution did you used? – Vincent Guerci Sep 15 '11 at 07:31
  • @Vincent I used the region format fix, that was a strange bug, i thought it had something to do with my HTML files embedded in my application haha.. – Richard J. Ross III Sep 15 '11 at 13:40
  • @Richard I see, too bad I was hoping for a fix by code, anyway thanks for your reply :) – Vincent Guerci Sep 15 '11 at 15:27
  • @fatfreddyscat where do you set the locale? – borisdiakur May 04 '12 at 09:01
  • @fatfreddyscat Ah, ok, I thought you had a programatical work around. Nevermind. And thanks! – borisdiakur May 08 '12 at 07:51
1

Well your exception code is EXC_BAD_ACCESS. This is generally a memory-management error (i.e. some bit of code tried to access an object that had already been released/dealloc'ed).

It is possible but very unlikely that this is a bug in Apple/framework code. It's more likely that somewhere in your code you are either over-releasing something or hanging on to an auto-released object instance or otherwise accessing something that shouldn't be accessed.

Given that the crash happened in MapKit, I'd recommend looking at your map-related code for possible sources of this crash. Note that MapKit can be a bit tempermental; I've seen crashes in cases such as attempting to access the LocationManager's current-location when the user has location-services turned off. I'd expect such a case to fail (for instance, by returning a nil location), but not to crash the app.

aroth
  • 54,026
  • 20
  • 135
  • 176
  • Yes, I realize what 'EXC_BAD_ACCESS' is and I've tried looking at all of my Mapkit references for such things as erroneous releases, etc. The problem really lies in the fact that, out of hundreds of devices, we're only seeing this crash on 2 and, furthermore, the crash seemed to only start occurring post iOS 4.3 release. Also, the crash is at application startup which makes it all the more difficult to determine why/where something may have been over-released or set to nil, etc. (i.e. when the crash occurs, at that point, my code has yet to touch anything MapKit related). – fatfreddyscat Apr 13 '11 at 23:05
  • I'll keep looking but it really seems as though somehow the MapKit call to 'goToDefaultLocation' is resulting in a location that causes the CFStringGetLength to crash... – fatfreddyscat Apr 13 '11 at 23:08
  • What would be great is to get what code it sends to `[ALCityManager localeWithCode:]` and **how** it determines it. Tried breakpointing it? – Vincent Guerci Apr 15 '11 at 10:22
  • Look at that : http://stackoverflow.com/questions/3327828/xcode-gdb-how-to-get-information-about-an-exception-that-was-just-thrown What you need i think is 1. in gdb `fb -[ALCityManager localeWithCode:]` 2. on breakpoint hit `po $r0` – Vincent Guerci Apr 15 '11 at 10:24
  • Forgot to update this -> turns out that it is a bug in Apple's code per iOS 4.3 update. The workaround is to set the locale to something other than En then, set it back. FYI. Waiting on a fix. – fatfreddyscat May 03 '11 at 07:23
  • was a fix ever released for this? I'm seeing something similar in the latest 4.3.5 – tutts Jul 29 '11 at 12:15
  • @fatfreddyscat where do you set the locale? – borisdiakur May 03 '12 at 15:50
  • @Lego -> please look at my comment on the original question which I posted at May 5, 2011 at 17:27. The instructions are there (e.g. where I say "go to their Settings->General->International->Region Format and set it to something other than 'United States' and set it back") – fatfreddyscat May 08 '12 at 00:05