2

I have a project that simply pauses, and does not crash. It pauses at the last line in this set:

 NSLog(@"%@", nibOptions);
 NSLog(@"%@", self.nibName);
 NSLog(@"%@", self.nibBundle);

 [self.nibBundle loadNibNamed:self.nibName owner:self options:nibOptions];

The NSLogs that precede the pause look totally reasonable. I think everything is connected up correctly. But obviously something is wrong. Any advice on troubleshooting a pause that gives no info? There are no break points set. Thanks. (Xcode 4.2)

EDIT: I'd add that the app comes to the front, then moves behind the Xcode window. The nib/view does not load.

EDIT: Here's the crash log (after the pause is continued):

#0  0x90160332 in __kill ()
#1  0x9015f932 in kill$UNIX2003 ()
#2  0x013e136b in CFHash ()
#3  0x01493c04 in __CFDictionaryStandardHashKey ()
#4  0x013e9114 in CFBasicHashFindBucket ()
#5  0x013e8ad5 in CFDictionaryGetValue ()
#6  0x00588ba4 in +[UIProxyObject mappedObjectForCoder:withIdentifier:] ()
#7  0x00588c9d in -[UIProxyObject initWithCoder:] ()
#8  0x00687fa2 in UINibDecoderDecodeObjectForValue ()
#9  0x006876b7 in -[UINibDecoder decodeObjectForKey:] ()
#10 0x00588ead in -[UIRuntimeConnection initWithCoder:] ()
#11 0x00589629 in -[UIRuntimeEventConnection initWithCoder:] ()
#12 0x00687fa2 in UINibDecoderDecodeObjectForValue ()
#13 0x006879af in UINibDecoderDecodeObjectForValue ()
#14 0x006876b7 in -[UINibDecoder decodeObjectForKey:] ()
#15 0x00588305 in -[UINib instantiateWithOwner:options:] ()
#16 0x0058a010 in -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] ()
#17 0x00002fc5 in -[P3ViewController loadView] at /Users/bryanhanson/Desktop/NastyMarty/P3/Classes/P3ViewController.m:158
#18 0x004305cb in -[UIViewController view] ()
#19 0x00390a73 in -[UIWindow addRootViewControllerViewIfPossible] ()
#20 0x00390ce2 in -[UIWindow _setHidden:forced:] ()
#21 0x00390ea8 in -[UIWindow _orderFrontWithoutMakingKey] ()
#22 0x00397d9a in -[UIWindow makeKeyAndVisible] ()
#23 0x0000297e in -[P3AppDelegate application:didFinishLaunchingWithOptions:] ()
#24 0x003689d6 in -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] ()
#25 0x003698a6 in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] ()
#26 0x00378743 in -[UIApplication handleEvent:withNewEvent:] ()
#27 0x003791f8 in -[UIApplication sendEvent:] ()
#28 0x0036caa9 in _UIApplicationHandleEvent ()
#29 0x01bc7fa9 in PurpleEventCallback ()
#30 0x014a51c5 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#31 0x0140a022 in __CFRunLoopDoSource1 ()
#32 0x0140890a in __CFRunLoopRun ()
#33 0x01407db4 in CFRunLoopRunSpecific ()
#34 0x01407ccb in CFRunLoopRunInMode ()
#35 0x003692a7 in -[UIApplication _run] ()
#36 0x0036aa9b in UIApplicationMain ()
#37 0x00002458 in main ()
Bryan Hanson
  • 6,055
  • 4
  • 41
  • 78
  • 1
    When it pauses there, can you resume as if there were really a break point? Also, was there a breakpoint in that line or on a line near it and that you removed recently? – sch Feb 18 '12 at 02:25
  • There were breakpoints in there at one time, apparently added automagically, as I didn't do it. I removed them. Do I need to tidy up somehow? If I continue, it does die completely. – Bryan Hanson Feb 18 '12 at 02:29
  • Dies completely: you mean crashes? – sch Feb 18 '12 at 02:31
  • Yes, crashes. The bad line is simply labeled "Thread 1" in green background when it pauses. If I continue, SIGKILL is issued. – Bryan Hanson Feb 18 '12 at 02:40
  • Is that the log when the app is paused or after you resume it (this is what we need)? – sch Feb 18 '12 at 03:00
  • Sorry, changed the crash log to the situation after continuing to the crash. – Bryan Hanson Feb 18 '12 at 03:04
  • What was the outcome on this (i.e. how did you solve it)? – matt Feb 22 '12 at 14:03
  • @matt Well, I'd put it in the category of "corrupted nib" but I think of course I may have been the true cause. It does seem to be a true crash. I have not entirely fixed it yet due to lack of time, but I went back to an earlier, less-featured but working version and am building up the nib and making the connections fresh. Lesson for me: save way more often (I'm using the snapshot feature now after every modest move until I gain more confidence!). – Bryan Hanson Feb 22 '12 at 18:42
  • Thanks for reporting back. I'd suggest filing a bug, esp. if you have the corrupted nib - a bug on the fact that you didn't get any error message in the console. – matt Feb 22 '12 at 19:00

4 Answers4

2

The window moves behind Xcode because it gains focus when your app pauses/crashes. And the view doesn't load because the you just called loadnib or did not yet (depending on the line where the app pauses).

Now, as you say that your app dies if you resume running it, then it is a crash and not a pause.

Try to verify that the nib name and options are correct, and that the xib file is actually there and bundled with the app.

Edit

Try the solution in the accepted answer here.

It's crashing in NibDecoder, i.e. when loading your XIB files. You probably have a reference in there to an object or property that doesn't exist or isn't initialized.

And the conclusion of the OP:

I built everything up again from scratch in my custom controller object and i've bypassed what was killing me last time. Every single change I made I compiled and ran in the iPhone sim to make sure I didn't trip myself up. I think my connections to my Controller object must have been incorrect and I was doing something else. So lesson learned is compile and test a lot when doing IB layouts... not just when using Xcode!

So just try doing like him: verifying the connections in the xib file, or if possible, start it again and add thing step by step to see what is causing the crash.

Community
  • 1
  • 1
sch
  • 27,436
  • 3
  • 68
  • 83
  • Following some advice elsewhere on SO, I did check the nib name was correct. I had NSLog give it to me, and over in attributes inspector it is of the right class. – Bryan Hanson Feb 18 '12 at 02:43
  • Thanks for the cross reference. I do have an earlier version that worked, I'll go back to that and build up from there, saving smaller changes more often. Thanks to everyone (this will take me into tomorrow most likely). – Bryan Hanson Feb 18 '12 at 03:24
0

It's not a pause, it's a crash that looks like a pause when you NSLog something of the wrong type. One of those NSLogs is not an object and cannot be displayed with "%@".

Nick
  • 9,792
  • 7
  • 50
  • 60
  • I agree, it's a crash or pending crash. The NSLogs aren't the problem. They weren't there when the problem started, I added them as part of troubleshooting. Commenting them out gives the same problem. – Bryan Hanson Feb 18 '12 at 02:38
  • Check any other cases of string formatting, this is a common pitfall. – Nick Feb 18 '12 at 02:43
  • All NSLog commented out, and the problem remains. This has to be something stupid. – Bryan Hanson Feb 18 '12 at 02:47
0

Hit pause, and take a look at your threads. I bet you have a circular inclusion somewhere. It will look something like this:

1 -[MyClass2 init]
2 -[MyClass1 init]
3 -[MyClass3 init]
4 -[MyClass2 init]
5 -[MyClass1 init]
6 -[MyClass3 init]
7 -[MyClass2 init]
8 -[MyClass1 init]
9 -[ApplicationDelegate appFinishedLaunching]
10 UIApplicationMain

It will crash eventually. But until it does, it just looks like it's waiting for something. Check for something where MyClass1 #imports MyClass2 which #imports MyClass3 which #imports MyClass1 all over again.

JoeCortopassi
  • 5,083
  • 7
  • 37
  • 65
  • Yes this is very probable, but would it always crash on the same line, or even the same class? – sch Feb 18 '12 at 02:56
  • Not always. It just basically keeps executing until it ties up all available resources and crashes the app. This can vary in when it causes your app to crash. The reason it pauses at the same spot, is probably due to the circular inclusion starting there – JoeCortopassi Feb 21 '12 at 18:14
  • That's what I thought. Anyways, the OP found the origin of is problem now. – sch Feb 21 '12 at 18:19
0

Is this on Snow Leopard? There's a bug where if the runtime crashes you and sends you a message explaining why, you don't get the message in the Console. For example, there could be something wrong with your nib so the nib-loading fails. But you're never getting the Console message explaining why.

EDIT: The best solution is to install Lion and run it on Lion; the bug doesn't happen there. Another possibility (this is what I do) is set a global exception on [NSException raise] and set breakpoints on. When the crash occurs, you will pause at that global breakpoint and you then type po $eax in the Console and you'll get the message from the runtime - if you're lucky.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Oops... I may have my animals confused: sorry. I'm on 10.7.3 – Bryan Hanson Feb 18 '12 at 03:19
  • Hmm. Well, you could still try what I said. You are clearly crashing as the nib tries to load; it's weird that the Console is not showing you the message from the runtime. Typical reasons for this kind of crash would be, say, the File's Owner's view outlet is not connected, or the File's Owner is the wrong class (doesn't match the actual owner when the nib loads). Oh, and I'd also install Xcode 4.3, you never know and it can't hurt. – matt Feb 18 '12 at 03:28
  • Will upgrade Xcode shortly. Where do I put the [NSException raise] statement? – Bryan Hanson Feb 18 '12 at 03:35
  • Basically you want to do the equivalent of this: http://stackoverflow.com/questions/1163981/how-to-add-a-breakpoint-to-objc-exception-throw But looking at your crash log I think you may just have to scrap your nib and start over; it may be corrupt. (I see that you've gotten that suggestion already and I think it's right.) – matt Feb 18 '12 at 03:58