应用程序总是在不同的点崩溃,这取决于编译器优化



如果编译器优化= None,我的应用程序运行良好。

如果优化= Fast [-O, -O1],在一个点上持续崩溃,如果设置为-O2, -O3或-Ofast,在另一个点上持续崩溃,如果设置为-O,在另一个点上持续崩溃。

所有崩溃都发生在viewDidLoad启动序列中,并且始终是EXC_BAD_ACCESS

仅在iPad1/iOS5.1.1上运行时发生崩溃。无论优化设置如何,iPad4/iOS7.1都不会崩溃。

它曾经很好,但最近它坏了-回滚到以前的工作版本,现在也崩溃了,看起来可能是由于Xcode/SDK版本。

我在Mac OS X 10.8.5上使用Xcode 5.1。基础SDK =最新的iOS (iOS 7.1);iOS部署目标= iOS 5.0.

我的问题是:基于以上信息,从这里开始调试的最佳方法是什么?我有点卡住了。

编辑:这里是使用-O3:

的崩溃日志
Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x6454f8e3
Crashed Thread:  0
Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libstdc++.6.dylib               0x36b78cd8 std::basic_ios<char, std::char_traits<char> >::tie() const + 0
1   libstdc++.6.dylib               0x36b91544 std::ostream::sentry::sentry(std::ostream&) + 20
2   libstdc++.6.dylib               0x36b93b86 std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int) + 22
3   KP v2 Dev                       0x0001817e performerApp::setBankSettingsFromXmlStruct(int) (performerApp.mm:2607)
4   KP v2 Dev                       0x0000cfc8 performerApp::setBankSettingsFromExternalFile(int) (performerApp.mm:2892)
5   KP v2 Dev                       0x00009862 performerApp::setup() (performerApp.mm:141)
6   KP v2 Dev                       0x00347750 Poco::PriorityDelegate<ofBaseApp, ofEventArgs, false>::notify(void const*, ofEventArgs&) (PriorityDelegate.h:168)
7   KP v2 Dev                       0x002e5dfa Poco::AbstractEvent<ofEventArgs, Poco::PriorityStrategy<ofEventArgs, Poco::AbstractPriorityDelegate<ofEventArgs> >, Poco::AbstractPriorityDelegate<ofEventArgs>, Poco::FastMutex>::notify(void const*, ofEventArgs&) (PriorityStrategy.h:81)
8   KP v2 Dev                       0x002e31a0 ofNotifySetup() (ofEventUtils.h:172)
9   KP v2 Dev                       0x00341246 -[ofxiOSEAGLView setup] (ofxiOSEAGLView.mm:0)
10  KP v2 Dev                       0x003498dc -[ofxiOSViewController viewDidLoad] (ofxiOSViewController.mm:54)
11  UIKit                           0x32c78c84 -[UIViewController view] + 160
12  UIKit                           0x32c7745a -[UIWindow addRootViewControllerViewIfPossible] + 38
13  UIKit                           0x32dfb774 -[UIWindow setRootViewController:] + 332
14  KP v2 Dev                       0x00348706 -[ofxiOSAppDelegate applicationDidFinishLaunching:] (ofxiOSAppDelegate.mm:170)
15  UIKit                           0x32c77cfa -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1262
16  UIKit                           0x32c717d6 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 402
17  UIKit                           0x32c3fabc -[UIApplication handleEvent:withNewEvent:] + 1004
18  UIKit                           0x32c3f560 -[UIApplication sendEvent:] + 48
19  UIKit                           0x32c3ef34 _UIApplicationHandleEvent + 5820
20  GraphicsServices                0x33231224 PurpleEventCallback + 876
21  CoreFoundation                  0x3551351c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
22  CoreFoundation                  0x355134be __CFRunLoopDoSource1 + 134
23  CoreFoundation                  0x3551230c __CFRunLoopRun + 1364
24  CoreFoundation                  0x3549549e CFRunLoopRunSpecific + 294
25  CoreFoundation                  0x35495366 CFRunLoopRunInMode + 98
26  UIKit                           0x32c70864 -[UIApplication _run] + 544
27  UIKit                           0x32c6dcce UIApplicationMain + 1074
28  KP v2 Dev                       0x00340600 ofAppiOSWindow::startAppWithDelegate(std::string) (ofAppiOSWindow.mm:96)
29  KP v2 Dev                       0x0034047e ofAppiOSWindow::runAppViaInfiniteLoop(ofBaseApp*) (ofAppiOSWindow.mm:84)
30  KP v2 Dev                       0x002dce9e ofRunApp(ofBaseApp*) (ofAppRunner.cpp:137)
31  KP v2 Dev                       0x00008f10 main (main.mm:32)
32  KP v2 Dev                       0x00008e00 start + 32
下面是使用-Os的崩溃日志:
Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x54442d1c
Crashed Thread:  0
Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libstdc++.6.dylib               0x36b6ab90 std::ios_base::_M_call_callbacks(std::ios_base::event) + 88
1   libstdc++.6.dylib               0x36b6ae48 std::ios_base::~ios_base() + 20
2   KP v2 Dev                       0x00031d38 std::string ofToString<int>(int const&) (basic_ios.h:268)
3   KP v2 Dev                       0x000593f4 BankData (BankData.mm:27)
4   KP v2 Dev                       0x00058bf2 ConfigData::init(int) (ConfigData.mm:28)
5   KP v2 Dev                       0x0000c082 performerApp::setup() (performerApp.mm:52)
6   KP v2 Dev                       0x00343700 Poco::PriorityDelegate<ofBaseApp, ofEventArgs, false>::notify(void const*, ofEventArgs&) (PriorityDelegate.h:168)
7   KP v2 Dev                       0x002e1daa Poco::AbstractEvent<ofEventArgs, Poco::PriorityStrategy<ofEventArgs, Poco::AbstractPriorityDelegate<ofEventArgs> >, Poco::AbstractPriorityDelegate<ofEventArgs>, Poco::FastMutex>::notify(void const*, ofEventArgs&) (PriorityStrategy.h:81)
8   KP v2 Dev                       0x002df150 ofNotifySetup() (ofEventUtils.h:172)
9   KP v2 Dev                       0x0033d1f6 -[ofxiOSEAGLView setup] (ofxiOSEAGLView.mm:0)
10  KP v2 Dev                       0x0034588c -[ofxiOSViewController viewDidLoad] (ofxiOSViewController.mm:54)
11  UIKit                           0x32c78c84 -[UIViewController view] + 160
12  UIKit                           0x32c7745a -[UIWindow addRootViewControllerViewIfPossible] + 38
13  UIKit                           0x32dfb774 -[UIWindow setRootViewController:] + 332
14  KP v2 Dev                       0x003446b6 -[ofxiOSAppDelegate applicationDidFinishLaunching:] (ofxiOSAppDelegate.mm:170)
15  UIKit                           0x32c77cfa -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1262
16  UIKit                           0x32c717d6 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 402
17  UIKit                           0x32c3fabc -[UIApplication handleEvent:withNewEvent:] + 1004
18  UIKit                           0x32c3f560 -[UIApplication sendEvent:] + 48
19  UIKit                           0x32c3ef34 _UIApplicationHandleEvent + 5820
20  GraphicsServices                0x33231224 PurpleEventCallback + 876
21  CoreFoundation                  0x3551351c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
22  CoreFoundation                  0x355134be __CFRunLoopDoSource1 + 134
23  CoreFoundation                  0x3551230c __CFRunLoopRun + 1364
24  CoreFoundation                  0x3549549e CFRunLoopRunSpecific + 294
25  CoreFoundation                  0x35495366 CFRunLoopRunInMode + 98
26  UIKit                           0x32c70864 -[UIApplication _run] + 544
27  UIKit                           0x32c6dcce UIApplicationMain + 1074
28  KP v2 Dev                       0x0033c5b0 ofAppiOSWindow::startAppWithDelegate(std::string) (ofAppiOSWindow.mm:96)
29  KP v2 Dev                       0x0033c42e ofAppiOSWindow::runAppViaInfiniteLoop(ofBaseApp*) (ofAppiOSWindow.mm:84)
30  KP v2 Dev                       0x002d8e4e ofRunApp(ofBaseApp*) (ofAppRunner.cpp:137)
31  KP v2 Dev                       0x0000bbe0 main (main.mm:32)
32  KP v2 Dev                       0x0000bad0 start + 32

通常当某些东西在更高的优化而不是在- 0时崩溃时,这意味着您要么使用未初始化的变量,要么使用已释放的对象。在- 0时,大量的数据在被使用后被闲置,而在更高的优化下,数据被更积极地重用。Xcode静态分析器对于查找未初始化的变量使用非常方便。使用Guard Malloc(可在Xcode Run方案的Diagnostics窗格中设置)运行将在free发生后捕获使用,而不是在下游的某个时间。

答案是,这是一个Xcode的错误。修复于Xcode 5.1.1。

来自Xcode发布日志:

已解决的问题:当目标为iOS 5.1.1时,编译代码崩溃(16485980)

最新更新