EXC_BAD_ACCESS 在设备上,但在模拟器上很好 [英] EXC_BAD_ACCESS on device, but fine on Simulator
问题描述
我有一个在模拟器上运行良好的滚动视图应用程序,但是,当我安装在设备上时,当我尝试滚动一页时,它会给我一个 EXC_BAD_ACCESS.我已经通过具有分配和泄漏的仪器运行它,但没有任何泄漏,也没有僵尸消息...我只是好奇是什么可能导致模拟器与设备之间的这种差异?任何调试方法,因为我的符号化崩溃日志(部分如下),似乎不是很符号化.
I have a scroll view app which runs fine on the simulator, however, when installed on the device, it gives me an EXC_BAD_ACCESS, when i attempt to scroll one page. I have ran it through Instruments with Allocations and Leaks, but nothing is leaked and no zombies are messaged... i'm just curious what could cause such a difference in simulator vs device? Any ways to debug this, since my symbolicated crash log (partial below), doesn't seem to be very symbolicated.
异常类型:EXC_BAD_ACCESS (SIGBUS)
异常代码:0x0000000f 处的 KERN_PROTECTION_FAILURE
崩溃的线程:0
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000f
Crashed Thread: 0
线程 0 崩溃:
0 libobjc.A.dylib 0x0000286e objc_msgSend + 18
1 我的应用程序 0x00004fee 0x1000 + 16366
2 UIKit 0x000668f4 -[UIViewController 视图] + 104
3 我的应用程序 0x00009716 0x1000 + 34582
4 我的应用程序 0x0000960c 0x1000 + 34316
5 UIKit 0x0001426c -[UIScrollView setContentOffset:] + 344
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000286e objc_msgSend + 18
1 MyApp 0x00004fee 0x1000 + 16366
2 UIKit 0x000668f4 -[UIViewController view] + 104
3 MyApp 0x00009716 0x1000 + 34582
4 MyApp 0x0000960c 0x1000 + 34316
5 UIKit 0x0001426c -[UIScrollView setContentOffset:] + 344
谢谢
推荐答案
您在模拟器中的代码可能有错误,但不会触发 EXC_BAD_ACCESS 只是因为您取消引用的指针不在未映射的内存中.一个指针可能是坏的,可以访问,但没有被检测到——它仍然是一个错误.
Your code in the simulator could have the bug, but isn't triggering EXC_BAD_ACCESS by just the luck that a pointer that you dereference is not in unmapped memory. A pointer could be bad, and accessed, but not detected -- it's still a bug.
你已经检查了没有僵尸消息,这本来是我的第一个建议.
You have already checked to see that no Zombies are messaged, which would have been my first suggestion.
接下来要做的是启用 Guard Malloc -- 然后阅读本文
The next thing to do is Enable Guard Malloc -- and then read this
您只能在模拟器中执行此操作——您的目标是使用超敏感堆使错误在模拟器中抛出 EXC_BAD_ACCESS.
You can only do this in the simulator -- your goal is to use the extra-sensitive heap to make the bug throw EXC_BAD_ACCESS in the simulator.
在文章中:
- 看看如何在GDB中设置变量
- 阅读检测堆损坏"部分
这篇关于EXC_BAD_ACCESS 在设备上,但在模拟器上很好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!