Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal Exception: NSInvalidArgumentException *** setObjectForKey: object cannot be nil (key: v_Data) #961

Closed
brad36 opened this issue Mar 18, 2015 · 13 comments

Comments

@brad36
Copy link

brad36 commented Mar 18, 2015

Got the following error running SDK3.0 on iOS7.1.2

Fatal Exception: NSInvalidArgumentException *** setObjectForKey: object cannot be nil (key: v_Data)

0 CoreFoundation 0x2eda6ecb exceptionPreprocess + 130
1 libobjc.A.dylib 0x39980ce7 objc_exception_throw + 38
2 CoreFoundation 0x2ece217f -[__NSDictionaryM setObject:forKey:] + 818
3 iPath 0x001f4699 -[SFKeychainItemWrapper setObject:forKey:]
4 iPath 0x001f5189 -[SFKeychainItemWrapper setValueData:]
5 iPath 0x00325bd7 +SFSecurityLockout writeLockoutTimeToKeychain:
6 iPath 0x00322483 +SFSecurityLockout upgradeSettings
7 iPath 0x00321ed3 +SFSecurityLockout initialize
8 libobjc.A.dylib 0x39981559 _class_initialize + 572
9 libobjc.A.dylib 0x39985a0f lookUpImpOrForward + 130
10 libobjc.A.dylib 0x39985983 _class_lookupMethodAndLoadCache3 + 34
11 libobjc.A.dylib 0x3998a8b9 _objc_msgSend_uncached + 24
12 iPath 0x0034c8e9 -SalesforceSDKManager savePasscodeActivityInfo
13 iPath 0x0034bfbb -SalesforceSDKManager handleAppBackground:
14 CoreFoundation 0x2ed68f01 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER
+ 12
15 CoreFoundation 0x2ecdcd69 _CFXNotificationPost + 1720
16 Foundation 0x2f6c8cc5 -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
17 UIKit 0x3165b511 -[UIApplication _handleApplicationSuspend:eventInfo:] + 912
18 UIKit 0x315dd213 -[UIApplication handleEvent:withNewEvent:] + 890
19 UIKit 0x315dcdd9 -[UIApplication sendEvent:] + 72
20 iPath 0x0030bead -SFApplication sendEvent:
21 UIKit 0x316413e5 _UIApplicationHandleEvent + 616
22 GraphicsServices 0x33c14b55 _PurpleEventCallback + 608
23 GraphicsServices 0x33c1473f PurpleEventCallback + 34
24 CoreFoundation 0x2ed71807 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 34
25 CoreFoundation 0x2ed717a3 __CFRunLoopDoSource1 + 346
26 CoreFoundation 0x2ed6ff6f __CFRunLoopRun + 1406
27 CoreFoundation 0x2ecda729 CFRunLoopRunSpecific + 524
28 CoreFoundation 0x2ecda50b CFRunLoopRunInMode + 106
29 GraphicsServices 0x33c136d3 GSEventRunModal + 138
30 UIKit 0x3163b871 UIApplicationMain + 1136
31 iPath 0x0010fc0b main (main.m:33)
32 libdyld.dylib 0x39e7eab7 start + 2

@bhariharan
Copy link
Contributor

@brad36 Are you able to reproduce this on Mobile SDK 3.2?

@brad36
Copy link
Author

brad36 commented May 20, 2015

Hi Bharath, no not yet, haven't really tried, or had 3.2 in production. We are planning to upgrade to 3.2 within the next couple of months, so when that goes into production, if its still an issue, we should see it come up in Crashlytics eventually

@bhariharan
Copy link
Contributor

@brad36 Thanks for checking. We've made some bug fixes in that area in 3.1 and 3.2, so if this issue exists in 3.2, feel free to reopen this issue.

@tomjtobin
Copy link

We are still seeing this in 3.2, stacktrace is eerily similar, so it looks like the problem is still there:

3
App 0x0000000100be3a78 -[SFKeychainItemWrapper setObject:forKey:] + 432
4
App 0x0000000100be43b4 -[SFKeychainItemWrapper setValueData:] + 56
5
App 0x0000000100a74004 +SFSecurityLockout writeLockoutTimeToKeychain:
6
App 0x0000000100a71d60 +SFSecurityLockout upgradeSettings
7
App 0x0000000100a71950 +SFSecurityLockout initialize

@carlcarter
Copy link

Can confirm this also happens on 3.2.

I have typically seen this when a user has logged in successfully and then used the logout switch in settings.

On next launch the app attempts to set the lockout to 0 and fails with exc_bad_access

@carlcarter
Copy link

#0 0x00000001973dbbd0 in objc_msgSend ()
#1 0x000000018619504c in -__NSDictionaryM setObject:forKey:
#2 0x00000001006b2e88 in -SFKeychainItemWrapper setObject:forKey:
#3 0x00000001006b37c4 in -SFKeychainItemWrapper setValueData:
#4 0x00000001005df780 in +[SFSecurityLockout writeLockoutTimeToKeychain:] at /Users/e01944579/Dev/iOS/Salesforce_MyClient/Pods/SalesforceMobileSDK-iOS/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Security/SFSecurityLockout.m:691
#5 0x00000001005dcf0c in +[SFSecurityLockout setSecurityLockoutTime:] at /Users/e01944579/Dev/iOS/Salesforce_MyClient/Pods/SalesforceMobileSDK-iOS/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Security/SFSecurityLockout.m:258
#6 0x00000001005dd310 in +[SFSecurityLockout clearAllPasscodeState] at /Users/e01944579/Dev/iOS/Salesforce_MyClient/Pods/SalesforceMobileSDK-iOS/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Security/SFSecurityLockout.m:294
#7 0x00000001005dd290 in +[SFSecurityLockout clearPasscodeState] at /Users/e01944579/Dev/iOS/Salesforce_MyClient/Pods/SalesforceMobileSDK-iOS/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Security/SFSecurityLockout.m:283
#8 0x000000010058ea18 in -[SFAuthenticationManager clearAccountState:] at /Users/e01944579/Dev/iOS/Salesforce_MyClient/Pods/SalesforceMobileSDK-iOS/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Security/SFAuthenticationManager.m:820
#9 0x000000010058a4ec in -[SFAuthenticationManager logoutUser:] at /Users/e01944579/Dev/iOS/Salesforce_MyClient/Pods/SalesforceMobileSDK-iOS/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Security/SFAuthenticationManager.m:468
#10 0x000000010058a014 in -[SFAuthenticationManager logout] at /Users/e01944579/Dev/iOS/Salesforce_MyClient/Pods/SalesforceMobileSDK-iOS/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Security/SFAuthenticationManager.m:424
#11 0x00000001006327a0 in -[SalesforceSDKManager processLogoutAndUserSwitchSettings] at /Users/e01944579/Dev/iOS/Salesforce_MyClient/Pods/SalesforceMobileSDK-iOS/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Common/SalesforceSDKManager.m:453
#12 0x0000000100631870 in -[SalesforceSDKManager handleAppForeground:] at /Users/e01944579/Dev/iOS/Salesforce_MyClient/Pods/SalesforceMobileSDK-iOS/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Common/SalesforceSDKManager.m:337
#13 0x0000000186250ddc in CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER ()
#14 0x000000018618f370 in _CFXNotificationPost ()
#15 0x00000001870b3520 in -NSNotificationCenter postNotificationName:object:userInfo:
#16 0x000000018ad4fb14 in -UIApplication _handleApplicationActivationWithScene:transitionContext:completion:
#17 0x000000018ad4f0b4 in __88-[UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:]_block_invoke ()
#18 0x000000018ad4f00c in -UIApplication _handleApplicationLifecycleEventWithScene:transitionContext:completion:
#19 0x000000018ad426a8 in -UIApplication scene:didUpdateWithDiff:transitionContext:completion:
#20 0x000000018e679604 in __31-[FBSSerialQueue performAsync:]_block_invoke ()
#21 0x0000000186262d70 in CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK ()
#22 0x0000000186261e78 in __CFRunLoopDoBlocks ()
#23 0x000000018626049c in __CFRunLoopRun ()
#24 0x000000018618d1f4 in CFRunLoopRunSpecific ()
#25 0x000000018f4bf6fc in GSEventRunModal ()
#26 0x000000018ab1e10c in UIApplicationMain ()
#27 0x00000001000b69e4 in main at /Users/e01944579/Dev/iOS/Salesforce_MyClient/myClient/main.m:33
#28 0x0000000197a46a08 in start ()

@tomjtobin
Copy link

@bhariharan should we file as a new issue? or you can re-open this one?

@carlcarter
Copy link

@akhileshgupta as requested

I’ve added more debugging and it only seems to happen when the real device (iPad Air A1475, iOS 8.2) is connected to Xcode and running in debug. Even then, it does not always happen but it once it happens, it tends to keep happening for a period of time until I give up scratching my head and delete the container from the device.

I have enabled SFLogger and gone through multiple login/logout cycles with the device running on it’s own and detached from Xcode (6.2) and I haven’t seen the error since. Very odd and it may well be Xcode related but I’m not 100%. What I do know is, when it crashes, the value passed to writeLockoutTimeToKeychain is always 0 and is converted to an NSData value of <0000 0000>. It crashes at the point where it tries to execute the following step:

if (data != nil)
[keychainWrapper setValueData:data];

@tomjtobin
Copy link

We've seen it only when not connected to Xcode. It seems to be on install when there is no salesforce login there.

@tomjtobin
Copy link

Also, it seems to happen more on devices that are not logged into salesforce (and have not been) and where the app is running in the background (e.g. Background Fetch)

@dautovicharis
Copy link

Similar crash was happened.
Used salesForce SDK: SalesforceMobileSDK-iOS (3.3.0)
Device: iPhone 6
iOS: 8.2.0
JAILBREAK: NO
Environment: Production

Crash log:
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x0000000182d0e530 exceptionPreprocess
1 libobjc.A.dylib 0x0000000193ce40e4 objc_exception_throw
2 CoreFoundation 0x0000000182bf9348 -[__NSDictionaryM setObject:forKey:]
3 Myapp 0x00000001001f5e0c -[SFKeychainItemWrapper setObject:forKey:]
4 Myapp 0x00000001001f6748 -[SFKeychainItemWrapper setValueData:]
5 Myapp 0x0000000100274a28 +SFSecurityLockout writeLockoutTimeToKeychain:
6 Myapp 0x0000000100272784 +SFSecurityLockout upgradeSettings
7 Myapp 0x0000000100272374 +SFSecurityLockout initialize
8 libobjc.A.dylib 0x0000000193ce4bd0 _class_initialize
9 libobjc.A.dylib 0x0000000193cec9ac lookUpImpOrForward
10 libobjc.A.dylib 0x0000000193cf7db8 _objc_msgSend_uncached_impcache
11 Myapp 0x0000000100241734 -SFAuthenticationManager retrievedIdentityData
12 Myapp 0x000000010023df20 -SFAuthenticationManager loggedIn:
13 Myapp 0x00000001002423fc __62-[SFAuthenticationManager populateDefaultAuthErrorHandlerList]_block_invoke494 (SFAuthenticationManager.m:958)
14 Myapp 0x00000001002426b0 -SFAuthenticationManager processAuthError:authInfo:
15 Myapp 0x0000000100243644 -SFAuthenticationManager oauthCoordinator:didFailWithError:authInfo:
16 Myapp 0x000000010025182c -SFOAuthCoordinator notifyDelegateOfFailure:authInfo:
17 Myapp 0x0000000100254e40 -SFOAuthCoordinator refreshFlowConnectionTimerFired:
18 Foundation 0x0000000183c07514 __NSFireTimer
19 CoreFoundation 0x0000000182cc6c20 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION

20 CoreFoundation 0x0000000182cc68d0 __CFRunLoopDoTimer
21 CoreFoundation 0x0000000182cc431c __CFRunLoopRun
22 CoreFoundation 0x0000000182bf11f4 CFRunLoopRunSpecific
23 GraphicsServices 0x000000018c0136fc GSEventRunModal
24 UIKit 0x000000018758210c UIApplicationMain
25 Myapp 0x00000001000939a8 main (main.m:13)
26 libdyld.dylib 0x0000000194362a08 start

@georgeathanasopoulositt

Is there a possibility for this to happen when the device is locked, so that keychain is not really accessible?

@wmathurin
Copy link
Contributor

Keychain accessible attribute is set to kSecAttrAccessibleWhenUnlockedThisDeviceOnly
(see here).
It can be changed by calling setAccessibleAttribute (see here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants