XCode Instruments 未检测到带有 BAD_ACCESS 的僵尸

发布于 2024-12-15 10:30:00 字数 1981 浏览 1 评论 0原文

通常,当我尝试修复 BAD_ACCESS 错误时,我会打开 Xcode Instruments 并测试以查找导致错误的僵尸。

我正在使用 iPhone 5.0 模拟器运行我的应用程序。它以 BAD_ACCESS 停止,但 Instruments 不会标记任何僵尸。

当我使用 iPhone 4.3 模拟器运行该应用程序时,行为完全不同。在这种情况下,应用程序运行得很好,没有任何 BAD_ACCESS。

我正在使用 XCode 4.2。

可能会发生什么?

这是回溯:

(gdb) bt
#0  0x0167209b in objc_msgSend ()
#1  0x00002ff2 in -[BSViewController viewDidAppear:] (self=0x1, _cmd=0x12ddd81, animated=1 '\001') at BSViewController.m:42
#2  0x012616f8 in __CFStringAppendFormatCore ()
#3  0x011acb6c in _CFStringCreateWithFormatAndArgumentsAux ()
#4  0x0122bce8 in _CFLogvEx ()
#5  0x00b26b63 in NSLogv ()
#6  0x00b26ad5 in NSLog ()
#7  0x00009ffc in -[BSCTView buildFrames] (self=0x6a55f80, _cmd=0xd541) at BSCTView.m:96
#8  0x0000a5da in -[BSCTView layoutSubviews] (self=0x6a55f80, _cmd=0x66a6c4) at BSCTView.m:124
#9  0x001ff301 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#10 0x01284e72 in -[NSObject performSelector:withObject:] ()
#11 0x0283592d in -[CALayer layoutSublayers] ()
#12 0x0283f827 in CA::Layer::layout_if_needed ()
#13 0x027c5fa7 in CA::Context::commit_transaction ()
#14 0x027c7ea6 in CA::Transaction::commit ()
#15 0x0285330c in +[CATransaction flush] ()
#16 0x001bf4c6 in -[UIApplication _reportAppLaunchFinished] ()
#17 0x001bfbd6 in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] ()
#18 0x001ce743 in -[UIApplication handleEvent:withNewEvent:] ()
#19 0x001cf1f8 in -[UIApplication sendEvent:] ()
#20 0x001c2aa9 in _UIApplicationHandleEvent ()
#21 0x01748fa9 in PurpleEventCallback ()
#22 0x012571c5 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#23 0x011bc022 in __CFRunLoopDoSource1 ()
#24 0x011ba90a in __CFRunLoopRun ()
#25 0x011b9db4 in CFRunLoopRunSpecific ()
#26 0x011b9ccb in CFRunLoopRunInMode ()
#27 0x001bf2a7 in -[UIApplication _run] ()
#28 0x001c0a9b in UIApplicationMain ()
#29 0x000027a0 in main (argc=1, argv=0xbffff578) at main.m:16

Usually, when I try to fix a BAD_ACCESS error I open the Xcode Instruments and test to find the zombies that are causing the error.

I'm running my app with iPhone 5.0 simulator. It stops with BAD_ACCESS, but Instruments doesn't flags any zombie.

The behavior is totally different when I run the app with iPhone 4.3 simulator. In this case, the application runs very well without any BAD_ACCESS.

I'm using XCode 4.2.

What could be happening?

Here's the backtrace:

(gdb) bt
#0  0x0167209b in objc_msgSend ()
#1  0x00002ff2 in -[BSViewController viewDidAppear:] (self=0x1, _cmd=0x12ddd81, animated=1 '\001') at BSViewController.m:42
#2  0x012616f8 in __CFStringAppendFormatCore ()
#3  0x011acb6c in _CFStringCreateWithFormatAndArgumentsAux ()
#4  0x0122bce8 in _CFLogvEx ()
#5  0x00b26b63 in NSLogv ()
#6  0x00b26ad5 in NSLog ()
#7  0x00009ffc in -[BSCTView buildFrames] (self=0x6a55f80, _cmd=0xd541) at BSCTView.m:96
#8  0x0000a5da in -[BSCTView layoutSubviews] (self=0x6a55f80, _cmd=0x66a6c4) at BSCTView.m:124
#9  0x001ff301 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#10 0x01284e72 in -[NSObject performSelector:withObject:] ()
#11 0x0283592d in -[CALayer layoutSublayers] ()
#12 0x0283f827 in CA::Layer::layout_if_needed ()
#13 0x027c5fa7 in CA::Context::commit_transaction ()
#14 0x027c7ea6 in CA::Transaction::commit ()
#15 0x0285330c in +[CATransaction flush] ()
#16 0x001bf4c6 in -[UIApplication _reportAppLaunchFinished] ()
#17 0x001bfbd6 in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] ()
#18 0x001ce743 in -[UIApplication handleEvent:withNewEvent:] ()
#19 0x001cf1f8 in -[UIApplication sendEvent:] ()
#20 0x001c2aa9 in _UIApplicationHandleEvent ()
#21 0x01748fa9 in PurpleEventCallback ()
#22 0x012571c5 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#23 0x011bc022 in __CFRunLoopDoSource1 ()
#24 0x011ba90a in __CFRunLoopRun ()
#25 0x011b9db4 in CFRunLoopRunSpecific ()
#26 0x011b9ccb in CFRunLoopRunInMode ()
#27 0x001bf2a7 in -[UIApplication _run] ()
#28 0x001c0a9b in UIApplicationMain ()
#29 0x000027a0 in main (argc=1, argv=0xbffff578) at main.m:16

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

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

发布评论

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

评论(1

离旧人 2024-12-22 10:30:00

正如 @AdamRosenfield 上面所说,在问题评论中,EXC_BAD_ACCESS 可能是由许多其他非僵尸事物引起的。

在这种特定情况下,问题是 NSLog() 的格式字符串需要一个对象 @"%@" 并且正在接收 int > 作为参数,如下例。

int variable = 1;
NSLog(@"%@", variable);

这导致了 EXC_BAD_ACCESS

阅读回溯后,我看到了 #6 行,并搜索了代码上的所有 NSLog() 调用,最终找到了出错的那一行。

As said above by @AdamRosenfield, on question comments, EXC_BAD_ACCESS can be caused by many other things that aren't zombies.

In this specific case, the problem was an NSLog() with a format string that expected an object @"%@" and was receiving an int as a parameter, as the example bellow.

int variable = 1;
NSLog(@"%@", variable);

This was causing the EXC_BAD_ACCESS.

After reading the backtrace, I saw that line #6 and searched all NSLog() calls on code to finally found the one with error.

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