0

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. enter image description here

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?

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

Community
  • 1
  • 1
Stas
  • 9,925
  • 9
  • 42
  • 77
  • 1
    I think the question you linked to does have the right answer in it - your app isn't terminated because the watchdog **is not active** when running either with the debugger on device or in the simulator. – lxt Oct 02 '13 at 10:55
  • not really..see my edited question..currently the application is stuck for more than 5 minutes on device and I don't see any watchdogs around.. – Stas Oct 02 '13 at 11:24
  • it is terminated after about 5 minutes.. – Stas Oct 02 '13 at 11:29
  • 2
    Careful coding and debugging checks the code for potential bugs. Everything else just assists. Don't count on the assistance always being there. – Hot Licks Oct 02 '13 at 11:31
  • Just wonder if there is such mechanism because somewhat causes crash at startup – Stas Oct 02 '13 at 12:29
  • Note that you haven't described a problem. When debugging most "watchdog" timers are disabled. – Hot Licks Oct 02 '13 at 15:43

1 Answers1

0

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.

Robert J. Clegg
  • 7,231
  • 9
  • 47
  • 99