如何在 iPhone 应用程序崩溃后读取日志
这是我的情况:
我有一个集成了推送的应用程序(我们称之为 MyApp)。当应用程序出现时 从后台返回,我启动了通过推送注册用户的方法。这 app在开发者模式下测试了很长时间,运行良好。
今天,该应用程序由苹果公司发布。但该应用程序不再工作了。它 总是会崩溃,但仅在某些情况下: - 在 3G、Edge 或 GPRS 中,应用程序将在启动屏幕后立即崩溃 - 在 WiFi 或飞行模式下,应用程序将按预期工作
我还发现,当连接到您指定的 WiFi 时,应用程序将工作 无法访问(一旦出现 WiFi 标志,应用程序就不会崩溃 即使您无法使用 LAN 浏览互联网 连接到!)。
希望您能帮我解决错误消息,我不太明白 如何摆脱应用程序崩溃。如前所述,在开发人员中(在模拟器上 在我的 iPhone 上)它会正常工作!
我真的很感谢你的建议!
建议:
- 可达性文件中的某处出现问题
- 启动“registerForRemoteNotificationTypes”后出现问题
日志文件
Incident Identifier: CD5D1DFA-75E7-4042-B8C6-4DA8F2477852
CrashReporter Key: 639f660a06c84202b5bc3666882fda8532a610b3
Hardware Model: iPhone3,1
Process: myApp [1296]
Path: /var/mobile/Applications/06B7C009-BB46-4473-9221-C8924C3D7A81/myApp.app/myApp
Identifier: myApp
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2011-03-01 08:32:00.598 +0100
OS Version: iPhone OS 4.2.1 (8C148)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00050000
Crashed Thread: 0
Thread 0 Crashed:
0 libSystem.B.dylib 0x33b5fa3c strlen + 12
1 CoreFoundation 0x33a3e42e __CFStringAppendFormatCore + 2386
2 CoreFoundation 0x33a3daac _CFStringCreateWithFormatAndArgumentsAux + 64
3 CoreFoundation 0x33a5a924 _CFLogvEx + 64
4 Foundation 0x33625738 NSLogv + 56
5 Foundation 0x336256ec NSLog + 16
6 myApp 0x0000e42c PrintReachabilityFlags (Reachability.m:25)
7 myApp 0x0000e446 -[Reachability networkStatusForFlags:] (Reachability.m:147)
8 myApp 0x0000e518 -[Reachability currentReachabilityStatus] (Reachability.m:198)
9 myApp 0x000030f4 -[myAppAppDelegate configureTextField:imageView:reachability:] (myAppAppDelegate.m:278)
10 myApp 0x00003354 -[myAppAppDelegate updateInterfaceWithReachability:] (myAppAppDelegate.m:274)
11 myApp 0x00003bca -[myAppAppDelegate applicationDidFinishLaunching:] (myAppAppDelegate.m:25)
12 UIKit 0x3209ebfa -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 826
13 UIKit 0x3209a252 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 266
14 UIKit 0x32066484 -[UIApplication handleEvent:withNewEvent:] + 1108
15 UIKit 0x32065ec2 -[UIApplication sendEvent:] + 38
16 UIKit 0x32065900 _UIApplicationHandleEvent + 5084
17 GraphicsServices 0x33b0eefc PurpleEventCallback + 660
18 CoreFoundation 0x33a556f8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
19 CoreFoundation 0x33a556bc __CFRunLoopDoSource1 + 160
20 CoreFoundation 0x33a47f76 __CFRunLoopRun + 514
21 CoreFoundation 0x33a47c80 CFRunLoopRunSpecific + 224
22 CoreFoundation 0x33a47b88 CFRunLoopRunInMode + 52
23 UIKit 0x32099302 -[UIApplication _run] + 374
24 UIKit 0x32096e8c UIApplicationMain + 664
25 myApp 0x00003082 main (main.m:13)
26 myApp 0x00003018 start + 44
Thread 1:
0 libSystem.B.dylib 0x33b89974 kevent + 24
1 libSystem.B.dylib 0x33c33704 _dispatch_mgr_invoke + 88
2 libSystem.B.dylib 0x33c33174 _dispatch_queue_invoke + 96
3 libSystem.B.dylib 0x33c32b98 _dispatch_worker_thread2 + 120
4 libSystem.B.dylib 0x33bd724a _pthread_wqthread + 258
5 libSystem.B.dylib 0x33bcf970 start_wqthread + 0
Thread 2:
0 libSystem.B.dylib 0x33bd79e0 __workq_kernreturn + 8
1 libSystem.B.dylib 0x33bd7364 _pthread_wqthread + 540
2 libSystem.B.dylib 0x33bcf970 start_wqthread + 0
Thread 3:
0 libSystem.B.dylib 0x33b5d268 mach_msg_trap + 20
1 libSystem.B.dylib 0x33b5f354 mach_msg + 44
2 CoreFoundation 0x33a48648 __CFRunLoopServiceMachPort + 88
3 CoreFoundation 0x33a47ed2 __CFRunLoopRun + 350
4 CoreFoundation 0x33a47c80 CFRunLoopRunSpecific + 224
5 CoreFoundation 0x33a47b88 CFRunLoopRunInMode + 52
6 WebCore 0x304df124 RunWebThread(void*) + 332
7 libSystem.B.dylib 0x33bd6886 _pthread_start + 242
8 libSystem.B.dylib 0x33bcba88 thread_start + 0
Thread 0 crashed with ARM Thread State:
r0: 0x00050000 r1: 0x00000024 r2: 0x00000027 r3: 0x00000003
r4: 0x00000000 r5: 0x00050003 r6: 0x00000001 r7: 0x2fdfe348
r8: 0x2fdfd64c r9: 0x00000002 r10: 0x00000000 r11: 0x00000000
ip: 0x00050003 sp: 0x2fdfd43c lr: 0x33a3e435 pc: 0x33b5fa3c
cpsr: 0x200f0010
Binary Images:
[...]
Here is my situation:
I have an app (let's call it MyApp) that has push integrated. When the app comes
back from background, I launch the method to register users with push. The
app was tested in developer mode for a long time and it worked well.
Today the app was released by Apple. But the app doesn't work anymore. It
crashes all the time, but only under certain circumstances:
- in 3G, Edge or GPRS the app will crash right after the start screen
- in WiFi or airplane mode the app will work as expected
I also discovered that the app will work when connected to a WiFi that you
don't have access (as soon as the WiFi sign appears, the app doesn't crash
anymore, even if you can't browse the internet with the LAN you are
connected to!).
I hope you can help me with the error messages, I don't quite understand
how to get rid of the app crash. As mentioned, in developer (on Simulator
and on my iPhone) it will work properly!
I really appreciate your tips!
Suggestions:
- Problem somewhere in reachability file
- Problem after launching "registerForRemoteNotificationTypes"
Logfile
Incident Identifier: CD5D1DFA-75E7-4042-B8C6-4DA8F2477852
CrashReporter Key: 639f660a06c84202b5bc3666882fda8532a610b3
Hardware Model: iPhone3,1
Process: myApp [1296]
Path: /var/mobile/Applications/06B7C009-BB46-4473-9221-C8924C3D7A81/myApp.app/myApp
Identifier: myApp
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2011-03-01 08:32:00.598 +0100
OS Version: iPhone OS 4.2.1 (8C148)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00050000
Crashed Thread: 0
Thread 0 Crashed:
0 libSystem.B.dylib 0x33b5fa3c strlen + 12
1 CoreFoundation 0x33a3e42e __CFStringAppendFormatCore + 2386
2 CoreFoundation 0x33a3daac _CFStringCreateWithFormatAndArgumentsAux + 64
3 CoreFoundation 0x33a5a924 _CFLogvEx + 64
4 Foundation 0x33625738 NSLogv + 56
5 Foundation 0x336256ec NSLog + 16
6 myApp 0x0000e42c PrintReachabilityFlags (Reachability.m:25)
7 myApp 0x0000e446 -[Reachability networkStatusForFlags:] (Reachability.m:147)
8 myApp 0x0000e518 -[Reachability currentReachabilityStatus] (Reachability.m:198)
9 myApp 0x000030f4 -[myAppAppDelegate configureTextField:imageView:reachability:] (myAppAppDelegate.m:278)
10 myApp 0x00003354 -[myAppAppDelegate updateInterfaceWithReachability:] (myAppAppDelegate.m:274)
11 myApp 0x00003bca -[myAppAppDelegate applicationDidFinishLaunching:] (myAppAppDelegate.m:25)
12 UIKit 0x3209ebfa -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 826
13 UIKit 0x3209a252 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 266
14 UIKit 0x32066484 -[UIApplication handleEvent:withNewEvent:] + 1108
15 UIKit 0x32065ec2 -[UIApplication sendEvent:] + 38
16 UIKit 0x32065900 _UIApplicationHandleEvent + 5084
17 GraphicsServices 0x33b0eefc PurpleEventCallback + 660
18 CoreFoundation 0x33a556f8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
19 CoreFoundation 0x33a556bc __CFRunLoopDoSource1 + 160
20 CoreFoundation 0x33a47f76 __CFRunLoopRun + 514
21 CoreFoundation 0x33a47c80 CFRunLoopRunSpecific + 224
22 CoreFoundation 0x33a47b88 CFRunLoopRunInMode + 52
23 UIKit 0x32099302 -[UIApplication _run] + 374
24 UIKit 0x32096e8c UIApplicationMain + 664
25 myApp 0x00003082 main (main.m:13)
26 myApp 0x00003018 start + 44
Thread 1:
0 libSystem.B.dylib 0x33b89974 kevent + 24
1 libSystem.B.dylib 0x33c33704 _dispatch_mgr_invoke + 88
2 libSystem.B.dylib 0x33c33174 _dispatch_queue_invoke + 96
3 libSystem.B.dylib 0x33c32b98 _dispatch_worker_thread2 + 120
4 libSystem.B.dylib 0x33bd724a _pthread_wqthread + 258
5 libSystem.B.dylib 0x33bcf970 start_wqthread + 0
Thread 2:
0 libSystem.B.dylib 0x33bd79e0 __workq_kernreturn + 8
1 libSystem.B.dylib 0x33bd7364 _pthread_wqthread + 540
2 libSystem.B.dylib 0x33bcf970 start_wqthread + 0
Thread 3:
0 libSystem.B.dylib 0x33b5d268 mach_msg_trap + 20
1 libSystem.B.dylib 0x33b5f354 mach_msg + 44
2 CoreFoundation 0x33a48648 __CFRunLoopServiceMachPort + 88
3 CoreFoundation 0x33a47ed2 __CFRunLoopRun + 350
4 CoreFoundation 0x33a47c80 CFRunLoopRunSpecific + 224
5 CoreFoundation 0x33a47b88 CFRunLoopRunInMode + 52
6 WebCore 0x304df124 RunWebThread(void*) + 332
7 libSystem.B.dylib 0x33bd6886 _pthread_start + 242
8 libSystem.B.dylib 0x33bcba88 thread_start + 0
Thread 0 crashed with ARM Thread State:
r0: 0x00050000 r1: 0x00000024 r2: 0x00000027 r3: 0x00000003
r4: 0x00000000 r5: 0x00050003 r6: 0x00000001 r7: 0x2fdfe348
r8: 0x2fdfd64c r9: 0x00000002 r10: 0x00000000 r11: 0x00000000
ip: 0x00050003 sp: 0x2fdfd43c lr: 0x33a3e435 pc: 0x33b5fa3c
cpsr: 0x200f0010
Binary Images:
[...]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现问题出在 Reachability 类中。显然它在这里:
所以问题出在
"networkStatusForFlags"
字符串上。它在长度计算期间崩溃,可能是因为最后不是“\0”字符,而是一些垃圾并且访问了一些额外的内存。尝试像这样改变它:I see that the problem is in Reachability class. Obviously it is here:
So the problem is with
"networkStatusForFlags"
string. It crashes during length calculation probably because instead of '\0' character in the end there is some garbage and some extra memory is accessed. Try to change it like this: