对 IOS 应用程序上神秘的 EXC_BAD_ACCESS 进行故障排除

发布于 2024-12-13 06:41:23 字数 1339 浏览 3 评论 0原文

当我运行 IOS 应用程序(在 iPad 模拟器或真实设备上)时,出现 EXC_BAD_ACCESS 错误。通常情况下,我对此进行故障排除不会有任何问题,但错误来自系统本身的深处,在四处搜索后,我陷入了如何继续进行故障排除的困境。

谁能给我一些想法发生了什么或如何解决这个问题?我正在处理一个巨大的项目,如果错误消息中没有任何指示,我不知道从哪里开始。

谢谢!

#0  0x0230609b in objc_msgSend ()
#1  0x0206943d in CFRetain ()
#2  0x0214e9c0 in +[__NSArrayI __new::] ()
#3  0x020a200a in -[__NSPlaceholderArray initWithObjects:count:] ()
#4  0x009aa2dc in -[CALayerArray copyWithZone:] ()
#5  0x02164bd9 in -[NSObject copy] ()
#6  0x016bb0fa in -[UIView dealloc] ()
#7  0x02306e4d in _objc_rootRelease ()
#8  0x0206e435 in CFRelease ()
#9  0x0214fe94 in -[__NSArrayM dealloc] ()
#10 0x02306e4d in _objc_rootRelease ()
#11 0x02306e10 in objc_release ()
#12 0x02307c60 in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
#13 0x02096ed8 in _CFAutoreleasePoolPop ()
#14 0x012619f9 in -[NSAutoreleasePool release] ()
#15 0x0168af78 in _UIApplicationHandleEvent ()
#16 0x035dffa9 in PurpleEventCallback ()
#17 0x021361c5 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#18 0x0209b022 in __CFRunLoopDoSource1 ()
#19 0x0209990a in __CFRunLoopRun ()
#20 0x02098db4 in CFRunLoopRunSpecific ()
#21 0x02098ccb in CFRunLoopRunInMode ()
#22 0x016872a7 in -[UIApplication _run] ()
#23 0x01688a9b in UIApplicationMain ()
#24 0x0020f2a4 in main at /..../main.m:17

When I run my IOS application (on either the IPad simulator or real device) I get a EXC_BAD_ACCESS error. Normally I would have no problem troubleshooting this, but the error is coming deep from within the system itself, and after searching around I'm stuck how to proceed with the troubleshooting.

Can anyone give me some ideas what is going on or how to troubleshoot this? I am working with a huge project and without some indication from the error message I don't know where to start.

Thanks!

#0  0x0230609b in objc_msgSend ()
#1  0x0206943d in CFRetain ()
#2  0x0214e9c0 in +[__NSArrayI __new::] ()
#3  0x020a200a in -[__NSPlaceholderArray initWithObjects:count:] ()
#4  0x009aa2dc in -[CALayerArray copyWithZone:] ()
#5  0x02164bd9 in -[NSObject copy] ()
#6  0x016bb0fa in -[UIView dealloc] ()
#7  0x02306e4d in _objc_rootRelease ()
#8  0x0206e435 in CFRelease ()
#9  0x0214fe94 in -[__NSArrayM dealloc] ()
#10 0x02306e4d in _objc_rootRelease ()
#11 0x02306e10 in objc_release ()
#12 0x02307c60 in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
#13 0x02096ed8 in _CFAutoreleasePoolPop ()
#14 0x012619f9 in -[NSAutoreleasePool release] ()
#15 0x0168af78 in _UIApplicationHandleEvent ()
#16 0x035dffa9 in PurpleEventCallback ()
#17 0x021361c5 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#18 0x0209b022 in __CFRunLoopDoSource1 ()
#19 0x0209990a in __CFRunLoopRun ()
#20 0x02098db4 in CFRunLoopRunSpecific ()
#21 0x02098ccb in CFRunLoopRunInMode ()
#22 0x016872a7 in -[UIApplication _run] ()
#23 0x01688a9b in UIApplicationMain ()
#24 0x0020f2a4 in main at /..../main.m:17

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

丑疤怪 2024-12-20 06:41:23

我的第一个猜测是您正在发布一个已经自动发布的视图。例如:

UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[self.view addSubview:myButton]
[myButton release];

您还可以两次释放一个视图,或者释放一个其超级视图已消失的视图。

如果可能,您可以考虑将项目移至 ARC,因为它解决了大部分(但不是全部!)这些问题。否则,调试它的最佳选择可能是 #ifdef 删除部分代码,直到崩溃消失,然后将代码放回原处,直到再次崩溃。

My first guess would be that you are releasing a view that's already autoreleased. For example:

UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[self.view addSubview:myButton]
[myButton release];

You could also be releasing a view twice or perhaps releasing a view whose superview has gone away.

If possible, you might consider moving the project to ARC since it solves most (but not all!) of these issues. Otherwise, your best bet to debugging it is probably to #ifdef out portions of your code until the crash goes away and then put the code back in until it crashes again.

难以启齿的温柔 2024-12-20 06:41:23

从堆栈跟踪中,您可以计算出以下内容:

1)这与自动释放池有关

2)正在释放一个数组

3)我猜该数组包含一些UIView(可能)

4)作为UIView释放的一部分,有些事情正在发生严重错误

这没有那么有用,抱歉:)

堆栈跟踪开始处的自动释放告诉您,几乎可以肯定您没有保留足够的东西:)

是否有任何特定的视图中出现此错误发生?

From the stack trace you can work out the following :

1) It's to do with the autorelease pool

2) An array is being released

3) I guess that array contains some UIViews (maybe)

4) As part of UIView dealloc, something is going horribly wrong

That's not that helpful, sorry :)

The autorelease at the start of the stack trace tells you that it's almost certainly something that you have not retained something enough :)

Is there any particular view in which this error occurs?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文