【发布时间】:2011-12-29 20:09:43
【问题描述】:
通常,当我尝试修复 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
【问题讨论】:
-
EXC_BAD_ACCESS可能由无数种不同的可能错误引起,其中只有一个是僵尸对象。没有任何代码,这是不可能的。发生错误时的堆栈跟踪是什么? -
是的,我知道没有代码很难说,但是这里复制的代码非常大,而且 BAD_ACCESS 发生在不多说的地方。我正在编辑添加回溯的问题。
-
哇,
self=0x1是一个非常破碎的状态(回复:第 1 行)。 -
我从今天早上开始就在与这个错误作斗争,终于弄清楚了......对 NSLog 的调用正在接收一个 int 参数,并且我使用的是“Foo %@”而不是格式“食物”。我不知道为什么这不会在 4.3 模拟器上触发 BAD_ACCESS。
-
就在@AdamRosenfield 问我回溯的时候,我更加仔细地阅读了它,并在第 6 行看到了 NSLog。谢谢亚当!
标签: objective-c xcode instruments xcode4.2