导致NSUserDefaults崩溃的原因是什么?

时间:2018-01-15 15:07:59

标签: ios swift swift3 nsuserdefaults

我们在 2018-01-15 16:04:02.676 ERROR [org.springframework.boot.web.support.ErrorPageFilter:176] - Forwarding to error page from request [/status] due to exception [An Authentication object was not found in the SecurityContext] org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext at org.springframework.security.access.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:379) at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:223) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:124) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) 的例行阅读期间看到我们的用户群偶尔会发生崩溃。绝大多数用户没有遇到此问题,而那些用户没有运行任何特定版本的iOS。它似乎只是在我们开始使用Xcode 9.1进行部署之后才出现。

NSUserDefaults

以下是我们检索值的方法(Swift 3,通过Objective C调用):

EXC_BAD_ACCESS KERN_PROTECTION_FAILURE 0x000000016efe3fc0

Crashed: com.apple.main-thread
0  libswiftCore.dylib             0x101816d4c @objc _NSContiguousString.length() + 5720
1  CoreFoundation                 0x181e2a168 CFStringCompareWithOptionsAndLocale + 96
2  Foundation                     0x1828602fc -[NSString isEqualToString:] + 76
3  CoreFoundation                 0x181e19558 CFEqual + 596
4  CoreFoundation                 0x181e15414 CFBasicHashFindBucket + 344
5  CoreFoundation                 0x181e152a0 CFDictionaryGetValue + 224
6  CoreFoundation                 0x181ef0c74 -[CFPrefsSearchListSource alreadylocked_copyValueForKey:] + 108
7  CoreFoundation                 0x181f8f224 -[CFPrefsSource copyValueForKey:] + 64
8  CoreFoundation                 0x181f992c0 __76-[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:]_block_invoke + 40
9  CoreFoundation                 0x181ef44f0 __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:buttConfigurationURL:perform:]_block_invoke + 268
10 CoreFoundation                 0x181ef3d0c normalizeQuintuplet + 356
11 CoreFoundation                 0x181ef43d8 -[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:buttConfigurationURL:perform:] + 108
12 CoreFoundation                 0x181f99258 -[_CFXPreferences copyAppValueForKey:identifier:container:configurationURL:] + 124
13 CoreFoundation                 0x181f9bbbc _CFPreferencesGetAppBooleanValueWithContainer + 136
14 Foundation                     0x1828517a8 -[NSUserDefaults(NSUserDefaults) boolForKey:] + 112
15 <our code>                     0x100d80750 @objc SettingsPersistence.persistedBool.getter (SettingsPersistence.swift:90)

我认为这可能是一个线程问题,但这发生在主线程上。无论哪种方式,fileprivate static let PersistedBoolKey = "persistedBool" public var persistedBool: Bool { get { return UserDefaults.standard.bool(forKey: SettingsPersistence.PersistedBoolKey) } set(newPersistedBool) { UserDefaults.standard.set(newPersistedBool, forKey: SettingsPersistence.PersistedBoolKey) } } 都被记录为完全线程安全的。

这对我来说就像Apple的库中的低级错误。我该怎么做才能解决这个问题呢?我应该向谁报告?还有其他人遇到过类似的问题吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

自从将Xcode升级到9.4.1以来,此崩溃已消失。