zav*_*vié 1 singleton objective-c nscalendar ios objective-c-category
我们正在使用dateFromComponents:解析从服务器返回的日期字符串。
在极少数情况下,此调用会崩溃,但我们无法重现该错误。有没有人见过这种堆栈跟踪?
Thread 0:
0 libicucore.A.dylib 0x3b13514e _uprv_asciitolower + 18
1 libicucore.A.dylib 0x3b18757b _uloc_openKeywordList + 291
2 libicucore.A.dylib 0x3b135d7f _uloc_getName + 15
3 libicucore.A.dylib 0x3b135ba7 __ZN3icu6Locale4initEPKca + 175
4 libicucore.A.dylib 0x3b14f359 __ZN3icu6Locale14createFromNameEPKc + 57
5 libicucore.A.dylib 0x3b1b13db __ZN3icu8Calendar11setWeekDataERKNS_6LocaleEPKcR10UErrorCode + 131
6 libicucore.A.dylib 0x3b1b164f __ZN3icu8CalendarC2ERKNS_8TimeZoneERKNS_6LocaleER10UErrorCode + 123
7 libicucore.A.dylib 0x3b1d5857 __ZN3icu17GregorianCalendarC2ERKNS_8TimeZoneER10UErrorCode + 27
8 libicucore.A.dylib 0x3b1d5d7b __ZN3icu17GregorianCalendar18setGregorianChangeEdR10UErrorCode + 163
9 CoreFoundation 0x33728967 __CFCalendarSetupCal + 95
10 CoreFoundation 0x336a5db1 __CFCalendarComposeAbsoluteTimeV + 41
11 CoreFoundation 0x336b70d3 -[__NSCFCalendar dateFromComponents:] + 1139
12 <OurApp> 0x0015d7c5 -[NSString(<ACategory>) parsedDateFromyyyyMMddFormat] + 493
13 <OurApp> 0x000e28ab -[<AnNSOperation> finishedWithData:serverDate:] (<AnNSOperation>.m:154)
14 <OurApp> 0x0009ba87 __49-[<AnotherNSOperation> connectionDidFinishLoading:]_block_invoke (<AnotherNSOperation>.m:283)
15 libdispatch.dylib 0x3b9d0793 _dispatch_call_block_and_release + 11
16 libdispatch.dylib 0x3b9d05db _dispatch_client_callout + 23
17 libdispatch.dylib 0x3b9d3e45 __dispatch_main_queue_callback_4CF + 229
18 CoreFoundation 0x336f01b1 __CFRunLoopRun + 1289
19 CoreFoundation 0x3366323d _CFRunLoopRunSpecific + 357
20 CoreFoundation 0x336630c9 _CFRunLoopRunInMode + 105
21 GraphicsServices 0x3721e33b _GSEventRunModal + 75
22 UIKit 0x3557f2b9 _UIApplicationMain + 1121
23 <OurApp> 0x0006c151 main (main.m:32)
Run Code Online (Sandbox Code Playgroud)
我们还观察这样的堆栈跟踪:
Thread 20 Crashed:
0 libsystem_kernel.dylib 0x3c4fb350 ___pthread_kill + 8
1 libsystem_c.dylib 0x3c4ae36b _abort + 95
2 libc++abi.dylib 0x3ba56ddf abort_message + 75
3 libc++abi.dylib 0x3ba541cf ___cxa_pure_virtual + 19
4 libicucore.A.dylib 0x3bc02637 __ZN3icu8CalendarC2ERKNS_8TimeZoneERKNS_6LocaleER10UErrorCode + 99
5 libicucore.A.dylib 0x3bc26857 __ZN3icu17GregorianCalendarC2ERKNS_8TimeZoneER10UErrorCode + 27
6 libicucore.A.dylib 0x3bc26d7b __ZN3icu17GregorianCalendar18setGregorianChangeEdR10UErrorCode + 163
7 CoreFoundation 0x34189967 __CFCalendarSetupCal + 95
8 CoreFoundation 0x34106db1 __CFCalendarComposeAbsoluteTimeV + 41
9 CoreFoundation 0x341180d3 -[__NSCFCalendar dateFromComponents:] + 1139
Run Code Online (Sandbox Code Playgroud)
以下是方法:
Thread 0:
0 libicucore.A.dylib 0x3b13514e _uprv_asciitolower + 18
1 libicucore.A.dylib 0x3b18757b _uloc_openKeywordList + 291
2 libicucore.A.dylib 0x3b135d7f _uloc_getName + 15
3 libicucore.A.dylib 0x3b135ba7 __ZN3icu6Locale4initEPKca + 175
4 libicucore.A.dylib 0x3b14f359 __ZN3icu6Locale14createFromNameEPKc + 57
5 libicucore.A.dylib 0x3b1b13db __ZN3icu8Calendar11setWeekDataERKNS_6LocaleEPKcR10UErrorCode + 131
6 libicucore.A.dylib 0x3b1b164f __ZN3icu8CalendarC2ERKNS_8TimeZoneERKNS_6LocaleER10UErrorCode + 123
7 libicucore.A.dylib 0x3b1d5857 __ZN3icu17GregorianCalendarC2ERKNS_8TimeZoneER10UErrorCode + 27
8 libicucore.A.dylib 0x3b1d5d7b __ZN3icu17GregorianCalendar18setGregorianChangeEdR10UErrorCode + 163
9 CoreFoundation 0x33728967 __CFCalendarSetupCal + 95
10 CoreFoundation 0x336a5db1 __CFCalendarComposeAbsoluteTimeV + 41
11 CoreFoundation 0x336b70d3 -[__NSCFCalendar dateFromComponents:] + 1139
12 <OurApp> 0x0015d7c5 -[NSString(<ACategory>) parsedDateFromyyyyMMddFormat] + 493
13 <OurApp> 0x000e28ab -[<AnNSOperation> finishedWithData:serverDate:] (<AnNSOperation>.m:154)
14 <OurApp> 0x0009ba87 __49-[<AnotherNSOperation> connectionDidFinishLoading:]_block_invoke (<AnotherNSOperation>.m:283)
15 libdispatch.dylib 0x3b9d0793 _dispatch_call_block_and_release + 11
16 libdispatch.dylib 0x3b9d05db _dispatch_client_callout + 23
17 libdispatch.dylib 0x3b9d3e45 __dispatch_main_queue_callback_4CF + 229
18 CoreFoundation 0x336f01b1 __CFRunLoopRun + 1289
19 CoreFoundation 0x3366323d _CFRunLoopRunSpecific + 357
20 CoreFoundation 0x336630c9 _CFRunLoopRunInMode + 105
21 GraphicsServices 0x3721e33b _GSEventRunModal + 75
22 UIKit 0x3557f2b9 _UIApplicationMain + 1121
23 <OurApp> 0x0006c151 main (main.m:32)
Run Code Online (Sandbox Code Playgroud)
如果某事随机且很少发生,则是并发问题的危险信号。
NSCalendar 不是线程安全的,请确保在您的应用程序中每次使用当前日历都在同一线程上。
另外,我不知道 Arc 是否足够聪明,不会两次保留您已经单身的日历。