PhilipsHue / PhilipsHueSDK-iOS-OSX

The Software Development Kit for Philips Hue on iOS and OS X (beta)
579 stars 169 forks source link

PHBridgeSearching addBridgeToResultsWithIp:andMac:] tries to insert nil key in result NSDictionary #47

Closed tompalsma closed 10 years ago

tompalsma commented 10 years ago

On PHBridgeSearching.m line 114 -[PHBridgeSearching addBridgeToResultsWithIp:andMac:]

CoreFoundation -[__NSDictionaryM setObject:forKey:] + 818

Fatal Exception: NSInvalidArgumentException *\ setObjectForKey: key cannot be nil

I got the following stacktrace from a user:

Thread : Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x31289f4b __exceptionPreprocess + 130
1  libobjc.A.dylib                0x3b6ca6af objc_exception_throw + 38
2  CoreFoundation                 0x311c5667 -[__NSDictionaryM setObject:forKey:] + 818
3  App                            0x0011b8d5 -[PHBridgeSearching addBridgeToResultsWithIp:andMac:] (PHBridgeSearching.m:114)
4  App                            0x0011beef __57-[PHBridgeSearching getIPScanOperationForAdress:andPath:]_block_invoke (PHBridgeSearching.m:169)
5  Foundation                     0x31bc862f -[NSBlockOperation main] + 130
6  Foundation                     0x31bb87db -[__NSOperationInternal _start:] + 770
7  Foundation                     0x31c5c995 __NSOQSchedule_f + 60
8  libdispatch.dylib              0x3bbb368f _dispatch_async_redirect_invoke$VARIANT$mp + 110
9  libdispatch.dylib              0x3bbb4d71 _dispatch_root_queue_drain + 220
10 libdispatch.dylib              0x3bbb4f59 _dispatch_worker_thread2 + 56
11 libsystem_pthread.dylib        0x3bcefdbf _pthread_wqthread + 298
12 libsystem_pthread.dylib        0x3bcefc84 start_wqthread + 8

I think this happens in the startSearchWithCompletionHandler routine of PHBridgeSearching. The MAC and/or IP address are probably not nil-checked?

lightbow commented 10 years ago

I'm seeing this as well. I use TestFlight and saw about a dozen occurrences of essentially this same stack trace for my app today. It does appear to be down in the Philips SDK and out of our control.

lightbow commented 10 years ago

I've been seeing this on TestFlight. @tompalsma did you ever reproduce this yourself? I haven't been able to, but one thing I noticed is that dozens and dozens of threads are present, all looking like this (below) so it might be some operation-spawning process gone out of control.

0 Foundation 0x30ea5642 +[NSURLConnection sendSynchronousRequest:returningResponse:error:] 1 Lightbow 0x0005ae98 57-[PHBridgeSearching getIPScanOperationForAdress:andPath:]_block_invoke in PHBridgeSearching.m on Line 162 2 Foundation 0x30e5764e -[NSBlockOperation main] 3 Foundation 0x30e47874 -[NSOperationInternal _start:] 4 Foundation 0x30eeb744 __NSOQSchedule_f 5 libdispatch.dylib 0x3b19825e _dispatch_async_redirect_invoke 6 libdispatch.dylib 0x3b199688 _dispatch_root_queue_drain 7 libdispatch.dylib 0x3b1998dc _dispatch_worker_thread2 8 libsystem_pthread.dylib 0x3b2c4c16 _pthread_wqthread 9 libsystem_pthread.dylib 0x3b2c4adb start_wqthread

OS Version:7.1.1 Device name: iPhone Model:iPhone 5 CDMA+GSM Carrier: Telekom.de Timezone:MEZ Architecture:armv7s Connection State:Wifi Active

pverh commented 10 years ago

@tompalsma @lightbow: we have verified that this is a bug in our SDK, we will propably fix this issue in our upcoming release.