您的位置:首页 > 移动开发 > IOS开发

理解和分析ios应用的Crash Log

2016-05-31 18:44 507 查看

常见的错误类型

1).Bad Memory Accress[EXC_BAD_ACCESS // SIGSEGV // SIGBUS]

应用访问了非法内存。Exception Sub-code列出了被访问的资源的坏的内存地址。可以通过Instruments中的Zombies(僵尸对象分析器)来更好地分析此种错误。

2).Abnormal Exit[EXC_CRASH // SIGABRT]

这种异常是程序的异常退出。引起这种crash的大多数原因是OC中或C++中未捕获的异常引起的。

如果在应用的初始化方法中初始化过多的外部引用库(如第三方的静态库和动态库)也会导致应用crash。如果一个扩展的应用由于被杀死而挂起,生成的crash报告的异常类型会是LAUNCH_HANG.因为扩展的第三方库没有一个主要的功能,它可以在你应用中的任何初始化的代码中(任何时间)调用。所以你应该尽可能的推迟这些大量的工作。

3).Trace Trap[EXC_BREAKPOINT // SIGTRAP]

类似于一个异常退出,这个例外是为了使一个附加的调试器在其执行的特定点总断程序执行。你可以使用__builtin_trap()函数从自己的代码中引发该异常。如果没有附加调试器,则处理总值,并产生一个故障报告。

4.Guarded Resource Violation [EXC_GUARD]

The process violated a guarded resource protection. System libraries may mark certain file descriptors as guarded, after which normal operations on those descriptors will trigger an EXC_GUARD exception (when it wants to operate on these file descriptors, the system uses special ‘guarded’ private APIs). This helps you quickly track down issues such as closing a file descriptor that had been opened by a system library. For example, if an app closes the file descriptor used to access the SQLite file backing a Core Data store, Core Data would then crash mysteriously much later on. The guard exception gets these problems noticed sooner, and thus makes them easier to debug.

The associated Exception Subtype is a bitfield which breaks down as follows:

[63:61] - Guard Type: The type of the guarded resource. A value of 0x2 indicates the resource is a file descriptor.

[60:32] - Flavor: The conditions under which the violation was triggered.

If the first (1 << 0) bit is set, the process attempted to invoke close() on a guarded file descriptor.

If the second (1 << 1) bit is set, the process attempted to invoke dup(), dup2(), or fcntl() with the F_DUPFD or F_DUPFD_CLOEXEC commands on a guarded file descriptor.

If the third (1 << 2) bit is set, the process attempted to send a guarded file descriptor via a socket.

If the fifth (1 << 4) bit is set, the process attempted to write to a guarded file descriptor.

[31:0] - File Descriptor: The guarded file descriptor that the process attempted to modify.

5).Resource Limit [EXC_RESOURCE]

The process hit a resource consumption limit. This is not a crash, but a notification from the OS that the process is using too many resources. The exact resource is in the Exception Subtype field.

The exception subtype WAKEUPS indicates that a thread was waking up too many times per second, which forces the CPU to wake up very often and consumes battery life. You should investigate why this is happening and avoid it if possible.

The exception subtype MEMORY indicates that the process has crossed a memory limit imposed by the system. This may be a precursor to termination for excess memory usage.

6). Other Exception Types

Some crash reports may contain an un-named Exception Type, which will be printed as a hexadecimal value (e.g. 00000020). If you receive one of these crash reports, look directly to the Exception Codes field for more information.

The exception code 0xbaaaaaad indicates that the log is a stackshot of the entire system, not a crash report. To take a stackshot, push the Home button and any volume button. Often these logs are accidentally created by users, and do not indicate an error.

The exception code 0xbad22222 indicates that a VoIP application has been terminated by iOS because it resumed too frequently.

The exception code 0x8badf00d indicates that an application has been terminated by iOS because a watchdog timeout occurred. The application took too long to launch, terminate, or respond to system events. One common cause of this is doing synchronous networking on the main thread. Whatever operation is on Thread 0 needs to be moved to a background thread, or processed differently, so that it does not block the main thread.

The exception code 0xc00010ff indicates the app was killed by the operating system in response to a thermal event. This may be due to an issue with the particular device that this crash occurred on, or the environment it was operated in. For tips on making your app run more efficiently, see iOS Performance and Power Optimization with Instruments WWDC session.

The exception code 0xdead10cc indicates that an application has been terminated by iOS because it held on to a system resource (like the address book database) while running in the background.

The exception code 0xdeadfa11 indicated that an application has been force quit by the user. Force quits occur when the user first holds down the On/Off button until “slide to power off” appears, then holds down the Home button. It’s reasonable to assume that the user has done this because the application has become unresponsive, but it’s not guaranteed - force quit will work on any application.

Note: Terminating a suspended app by removing it from the multitasking tray does not generate a crash report. Once an app has suspended, it is eligible for termination by iOS at any time, so no crash report will be generated.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios 应用 exception