简体   繁体   中英

What mechanism checks the code for potential bugs?

If I put any code (eternal cycle like while(1) or sleep(xxxxx) ) that potentially can hang out main thread:

- (void)viewDidLoad
{
    [super viewDidLoad];
    while (1) {

    }
    //[NSThread sleepForTimeInterval:10000];
}

I'm getting SIGABORT just after launch in approximately 50% of launches. 在此处输入图片说明

What is going on? Though, if program is launched it is never (for at least 10 minutes) terminated as it should according to Synchronous Networking On The Main Thread . What about watchdog that should check application responsiveness and terminate the one that got stuck?

I presume that there's a question about this here but it doesn't contain meaningful answer though.

Tested both on simulator and device. The startup crash appears only on sim. Though the program is terminated neither on device nor on sim.

So there are actually two questions: 1. What about watchdog? 2. What is this startup crash on sim?

PS Sorry for my English I hope you've got what I mean.You're welcome to edit my post.

If your application is crashing then look at the code with the debugger. Add break point exceptions to the first view's -(void)viewDidLoad method as a starting point and see where it crashes. This normally exposes bugs quickly.

I suggested viewdidLoad as it is called the moment before the view comes to screen. If your very first screen is crashing - I'd start with its' viewDidLoad method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM