Unlocking Focus on wrong view ((null)) under OS X 10.7.2 - osx-lion

I have a Cocoa app that has an NSWindowController controlling an NSWindow with an NSComboBox in it. Nothing special, and it worked fine until upgrading to OS X 10.7.2. Now I get the following exception, which occurs only once, when the window controller's window loads. (Since the window controller in my app remains loaded, it happens only once per app launch.) Subsequently focusing and unfocusing the combo box does not trigger it.
Anyone know whether something changed in 10.7.2, and if so how to work around it?
(This is happening with Xcode 4.2.)
2011-10-24 11:30:21.649 MyApp[7934:707] Unlocking Focus on wrong view ((null)), expected <NSComboBox: 0x40083d6e0>
2011-10-24 11:30:21.653 MyApp[7934:707] (
0 CoreFoundation 0x00007fff8412d286 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff88cdad5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8412d0ba +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff8412d044 +[NSException raise:format:] + 116
4 AppKit 0x00007fff8c76c1d5 -[NSFocusStack unfocusView:] + 194
5 AppKit 0x00007fff8c7e838e +[_NSAutomaticFocusRing showForView:] + 2545
6 AppKit 0x00007fff8cdbb4d1 __postActiveFirstResponderChanged_block_invoke_1 + 32
7 CoreFoundation 0x00007fff840ecf37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
8 CoreFoundation 0x00007fff840ece96 __CFRunLoopDoObservers + 374
9 CoreFoundation 0x00007fff840c2159 __CFRunLoopRun + 825
10 CoreFoundation 0x00007fff840c1ae6 CFRunLoopRunSpecific + 230
11 HIToolbox 0x00007fff8c0d73d3 RunCurrentEventLoopInMode + 277
12 HIToolbox 0x00007fff8c0de58f ReceiveNextEventCommon + 181
13 HIToolbox 0x00007fff8c0de4ca BlockUntilNextEventMatchingListInMode + 62
14 AppKit 0x00007fff8c71e3f1 _DPSNextEvent + 659
15 AppKit 0x00007fff8c71dcf5 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
16 AppKit 0x00007fff8c71a62d -[NSApplication run] + 470
17 AppKit 0x00007fff8c99980c NSApplicationMain + 867
18 MyApp 0x0000000100001682 main + 34
19 MyApp 0x0000000100001654 start + 52
)

http://hints.macworld.com/index.php?topic=system107&page=5
This appears to have been a bug in OS X 10.7.* (Lion) series. With zero changes to my code, the crash no-longer occurs on OS X 10.8 (Mountain Lion) complied with Xcode 4.4.1.

You could try calling this command on the NSComboBox: setFocusRingType:NSFocusRingTypeNone
That should cure the problem, although it does not explain the difference between the two releases.

Related

sigsegv crash on iphone from crittercism

I've got a couple sigsegv crashes coming in from crittercism, but I'm not quite sure how to start going about debugging. The only line of code that's mine is the main call from the start of the crashed thread.
Copying the crashed thread's stack trace from crittercism:
Reason:
24-Sep-12
02:38:14 PM SIGSEGV
main (main.m:11)
Stack:
0
0 libobjc.A.dylib 0x356265b0 objc_msgSend + 15
1
1 UIKit 0x3861c313 + 1310
2
2 UIKit 0x386337cf + 206
3
3 UIKit 0x385ef80b + 258
4
4 QuartzCore 0x34f56d63 + 214
5
5 QuartzCore 0x34f56901 + 460
6
6 QuartzCore 0x34f57835 + 16
7
7 QuartzCore 0x34f5721b + 238
8
8 QuartzCore 0x34f57029 + 316
9
9 UIKit 0x386786e5 + 572
10
10 UIKit 0x386784a3 + 66
11
11 UIKit 0x38677391 + 1464
12
12 UIKit 0x385ed1ef + 2458
13
13 UIKit 0x385ec6d5 + 72
14
14 UIKit 0x385ec123 + 6154
15
15 GraphicsServices 0x3779f5a3 + 590
16
16 CoreFoundation 0x372f0683 + 14
17
17 CoreFoundation 0x372efee9 + 212
18
18 CoreFoundation 0x372eecb7 + 646
19
19 CoreFoundation 0x37261ebd CFRunLoopRunSpecific + 356
20
20 CoreFoundation 0x37261d49 CFRunLoopRunInMode + 104
21
21 GraphicsServices 0x3779e2eb GSEventRunModal + 74
22
22 UIKit 0x38640301 UIApplicationMain + 1120
23
23 MyApp 0x35bf main (main.m:11)
First, you'll need to "symbolicate" the crash log. There are plenty of web pages out there to instruct you on that.
Since this stack ends at objc_msgSend, the most likely cause is a dangling pointer.
To debug those, I recommend using NSZombies. If you are testing on the simulator, you might try "Guard malloc".
This crash is caused by invoking a method on a pointer to an object that was already deallocated. It is a very common ref count error somewhere in your code that holds on the UIKit elements. But, what you should do at a matter of practice is upload your .DSYM file to the crittercism. It can be done manually via the website or via a Web API call as part of your automatic build process.

How to compile for iPhone 4

here is my problem:
I have a fully working app which runs quite perfect on my iPhone 4S running iOS 5.1.1.
Now Apple rejected my app because they found that the app crashed upon launch on iPhone 4 running iOS 5.1.1. What do I have to do to compile for the iPhone 4? I can't really test it because I only have an iPhone 4S to my disposal. I already did some tweaking in the project settings and added armv6. What else do I have to do?
I symbolicated the crashreport I got from apple as you can see below.
However, the problem remains the same. I can not figure out why my app does not run on an iPhone 4. I found one piece of code that is mentioned as #6 of the last exceptions.
It is located in ViewController.m. This is my code at the specified line:
self.player =[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
Last Exception Backtrace:
0 CoreFoundation 0x3742088f __exceptionPreprocess + 163
1 libobjc.A.dylib 0x35125259 objc_exception_throw + 33
2 CoreFoundation 0x37420789 +[NSException raise:format:] + 1
3 CoreFoundation 0x374207ab +[NSException raise:format:] + 35
4 Foundation 0x37c0805f -[NSURL(NSURL) initFileURLWithPath:] + 79
5 Foundation 0x37c07ffb +[NSURL(NSURL) fileURLWithPath:] + 43
6 Podman 0x00021feb -[ViewController viewDidLoad] (ViewController.m:43)
7 UIKit 0x3112dc8b -[UIViewController view] + 167
8 UIKit 0x3112c461 -[UIWindow addRootViewControllerViewIfPossible] + 45
9 UIKit 0x3111ee87 -[UIWindow _setHidden:forced:] + 295
10 UIKit 0x3118f7d5 -[UIWindow makeKeyAndVisible] + 25
11 UIKit 0x3112ce6d -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1633
12 UIKit 0x311267dd -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 409
13 UIKit 0x310f4ac3 -[UIApplication handleEvent:withNewEvent:] + 1011
14 UIKit 0x310f4567 -[UIApplication sendEvent:] + 55
15 UIKit 0x310f3f3b _UIApplicationHandleEvent + 5827
16 GraphicsServices 0x33b3622b PurpleEventCallback + 883
17 CoreFoundation 0x373f4523 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 39
18 CoreFoundation 0x373f44c5 __CFRunLoopDoSource1 + 141
19 CoreFoundation 0x373f3313 __CFRunLoopRun + 1371
20 CoreFoundation 0x373764a5 CFRunLoopRunSpecific + 301
21 CoreFoundation 0x3737636d CFRunLoopRunInMode + 105
22 UIKit 0x3112586b -[UIApplication _run] + 551
23 UIKit 0x31122cd5 UIApplicationMain + 1081
24 Podman 0x00021e7b main (main.m:16)
25 Podman 0x00021e30 start + 40

Can we share controll file in an univarsal (iPhone, iPad) Application?

I developed a univarsal application,(iPhone, iPad). But later I tried to make them sepret, so i copied my folder in another directory and then linked my iPhone's control file with iPad's XIBs, and delegated them with Outlets, (my controll file remained in the iPhone folder, i just link them in iPad), after it i removed iPhone XIBs from this folder.
Now my project is working properly, BUT only if I execute the iPhone version first(even from that different directory), and then execute my iPad version, coz it share's the build file of iPhone.
But when I try to execute it Initially (after deleting prior installed version from simulator), it doesn't work, as it terminate after throwing following exception.
2011-04-23 10:56:01.831 Tuscany[1837:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** Call stack at first throw:
(
0 CoreFoundation 0x01683be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x014785c2 objc_exception_throw + 47
2 CoreFoundation 0x0163c628 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x0163c59a +[NSException raise:format:] + 58
4 Foundation 0x000d6b12 -[NSURL(NSURL) initFileURLWithPath:] + 90
5 Foundation 0x000d6aa0 +[NSURL(NSURL) fileURLWithPath:] + 72
6 Tuscany 0x0003572c -[SplashScreenViewController readyPlayer] + 77
7 Tuscany 0x00035a62 -[SplashScreenViewController viewDidLoad] + 296
8 UIKit 0x003e865e -[UIViewController view] + 179
9 UIKit 0x0035e026 -[UIWindow addRootViewControllerViewIfPossible] + 51
10 UIKit 0x0035d511 -[UIWindow _setHidden:forced:] + 303
11 UIKit 0x0035d301 -[UIWindow _orderFrontWithoutMakingKey] + 50
12 UIKit 0x0a2ac110 -[UIWindowAccessibility(SafeCategory) _orderFrontWithoutMakingKey] + 56
13 UIKit 0x0035bfb5 -[UIWindow makeKeyAndVisible] + 39
14 Tuscany 0x00003205 -[AppDelegate_iPad application:didFinishLaunchingWithOptions:] + 1472
15 UIKit 0x0033b1fa -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
16 UIKit 0x0033d55e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
17 UIKit 0x00347db2 -[UIApplication handleEvent:withNewEvent:] + 1533
18 UIKit 0x00340202 -[UIApplication sendEvent:] + 71
19 UIKit 0x00345732 _UIApplicationHandleEvent + 7576
20 GraphicsServices 0x01ce3a36 PurpleEventCallback + 1550
21 CoreFoundation 0x01665064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
22 CoreFoundation 0x015c56f7 __CFRunLoopDoSource1 + 215
23 CoreFoundation 0x015c2983 __CFRunLoopRun + 979
24 CoreFoundation 0x015c2240 CFRunLoopRunSpecific + 208
25 CoreFoundation 0x015c2161 CFRunLoopRunInMode + 97
26 UIKit 0x0033cfa8 -[UIApplication _run] + 636
27 UIKit 0x0034942e UIApplicationMain + 1160
28 Tuscany 0x00002b30 main + 102
29 Tuscany 0x00002ac1 start + 53
)
terminate called after throwing an instance of 'NSException'
here to mention i have worked hard with the line i'm establishing connection, and as i told same code run properly when I execute iPhone version first and then the iPad.
so please guied me with this,
thank you
What it says.
In the readyPlayer method you are trying to give a nil value to the fileUrlWithPath method.
You need to check why the path is nil.

App crashes but only when it's build for Ad-Hoc distro

My problem is this. I have an app that builds and runs fine in Debug mode, no crashes, memory errors, etc. As soon as I do an Ad-hoc build and try to run it on the device the main thread crashes at a certain point, for no apparent reason... The stack trace I managed to get from the device log is thus...
0 libSystem.B.dylib 0x30d7c2d4 __kill + 8
1 libSystem.B.dylib 0x30d7c2c4 kill + 4
2 libSystem.B.dylib 0x30d7c2b6 raise + 10
3 libSystem.B.dylib 0x30d90d72 abort + 50
4 libstdc++.6.dylib 0x34981a20 __gnu_cxx::__verbose_terminate_handler() + 376
5 libobjc.A.dylib 0x34a83594 _objc_terminate + 104
6 libstdc++.6.dylib 0x3497fdf2 __cxxabiv1::__terminate(void (*)()) + 46
7 libstdc++.6.dylib 0x3497fe46 std::terminate() + 10
8 libstdc++.6.dylib 0x3497ff16 __cxa_throw + 78
9 libobjc.A.dylib 0x34a824c4 objc_exception_throw + 64
10 CoreFoundation 0x3587a7c2 +[NSException raise:format:arguments:] + 62
11 CoreFoundation 0x3587a7fc +[NSException raise:format:] + 28
12 QuartzCore 0x31071222 CALayerSetPosition(CALayer*, CA::Vec2<double> const&, bool) + 134
13 QuartzCore 0x31071190 -[CALayer setPosition:] + 32
14 UIKit 0x341e4378 -[UIView(Geometry) setCenter:] + 16
15 MyApp 0x00012b2c 0x1000 + 72492
16 MyApp 0x0001276a 0x1000 + 71530
17 UIKit 0x341e3270 -[UIViewController view] + 104
18 UIKit 0x341efd04 -[UIViewController contentScrollView] + 16
19 UIKit 0x341efb74 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 24
20 UIKit 0x341efa72 -[UINavigationController _layoutViewController:] + 18
21 UIKit 0x341ef4cc -[UINavigationController _startTransition:fromViewController:toViewController:] + 248
22 UIKit 0x341ef358 -[UINavigationController _startDeferredTransitionIfNeeded] + 176
23 UIKit 0x341e30be -[UINavigationController pushViewController:transition:forceImmediate:] + 634
24 UIKit 0x341e2e34 -[UINavigationController pushViewController:animated:] + 28
25 MyApp 0x00004f80 0x1000 + 16256
26 UIKit 0x3420b834 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 656
27 UIKit 0x342cb60c -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 124
28 Foundation 0x31181df6 __NSFireDelayedPerform + 362
29 CoreFoundation 0x3583109c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
30 CoreFoundation 0x35830b54 __CFRunLoopDoTimer + 844
31 CoreFoundation 0x358021ae __CFRunLoopRun + 1082
32 CoreFoundation 0x35801c80 CFRunLoopRunSpecific + 224
33 CoreFoundation 0x35801b88 CFRunLoopRunInMode + 52
34 GraphicsServices 0x320c84a4 GSEventRunModal + 108
35 GraphicsServices 0x320c8550 GSEventRun + 56
36 UIKit 0x341dc322 -[UIApplication _run] + 406
37 UIKit 0x341d9e8c UIApplicationMain + 664
The other really strange thing is that if you close the app and stop it running (after the crash) in the background and then relaunch it, it bails out almost immediately quoting...
<Warning>: Application 'MyApp' exited abnormally with signal 11: Segmentation fault
Which I'm lead to believe is a memory access error (uninitialised memory access). I'm not doing anything crazy with pointers or anything so all I can presume is that it's a problem with the CF libraries...
Any thoughts or help would be HUGELY appreciated :)
It's hard to say exactly what the answer is without knowing more, but my first guess is that you are providing some invalid value to a UIView's center property.
There are two pieces of information missing that could help you/me find the answer.
First, lines like these in the stack trace need to be symbolicated:
15 MyApp 0x00012b2c 0x1000 + 72492
16 MyApp 0x0001276a 0x1000 + 71530
Knowing what is happening in those two lines will help you track it down, and knowing what the exception that got thrown (starting at line 11 in the stack trace) contains will help further. You may be able to get this information from looking at the device's Console output in Xcode's Organizer.
You can symbolicate the crash report if you have the dSYM file that was created when you built the app for AdHoc distribution. Dragging the crash report into Xcode's Organizer window will attempt to symbolicate it automatically. If that doesn't work, you can try using the symbolicatecrash script directly. It's tucked away in a path like this:
/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash

App Crashing in NSURLConnection

I am trying to figure out what is causing this crash. I have built and given the app to our testers but we cannot seem to reproduce this reliably. It just happens sometimes...
Thread 0 Crashed:
0 libobjc.A.dylib 0x000027da objc_msgSend + 18
1 Foundation 0x00032896 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 62
2 Foundation 0x00032818 _NSURLConnectionDidFinishLoading + 72
3 CFNetwork 0x00010dd8 URLConnectionClient::_clientDidFinishLoading(URLConnectionClient::ClientConnectionEventQueue*) + 160
4 CFNetwork 0x00004ad4 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo<XClientEvent, XClientEventParams>*, long) + 96
5 CFNetwork 0x000049c4 URLConnectionClient::processEvents() + 64
6 CFNetwork 0x00004976 URLConnection::multiplexerClientPerform(RunLoopMultiplexer*) + 30
7 CFNetwork 0x000048f4 MultiplexerSource::perform() + 120
8 CFNetwork 0x00004872 MultiplexerSource::_perform(void*) + 2
9 CoreFoundation 0x00055f1e __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6
10 CoreFoundation 0x00027ba0 __CFRunLoopDoSources0 + 376
11 CoreFoundation 0x00027444 __CFRunLoopRun + 224
12 CoreFoundation 0x00027270 CFRunLoopRunSpecific + 224
13 CoreFoundation 0x00027178 CFRunLoopRunInMode + 52
14 GraphicsServices 0x000045ec GSEventRunModal + 108
15 GraphicsServices 0x00004698 GSEventRun + 56
16 UIKit 0x0000411c -[UIApplication _run] + 396
17 UIKit 0x00002128 UIApplicationMain + 664
18 myapp 0x000020d8 main (main.m:14)
19 myapp 0x0000208c start + 32
Any advice would be greatly appreciated. The app is built in XCode 3.2.4 using SDK 4.1.
Cheers...
I would try turning on NSZombieEnabled and see if that sheds any light on the issue. Is the delegate for the connection still around and valid?
Ben has some sound advice. Turn NSZombieEnabled to on.
I can tell you with almost 100% certainty that it is crashing because you have a nil object when the delegate is attempting to send it a message.
The fact that it is only crashing sometimes, tells me that you are probably using autorelease. Autorelease never decrements the retain count at exactly the same time, so sometimes your object will still be alive when it gets a delegate message and the app works. However, sometimes that object will have been released and the app crashes.