如果 URLRequest 超时然后用户通过 Kerberos 进行身份验证,CFNetwork 会导致应用程序崩溃
CFNetwork crashes app if URLRequest timeout then user authenticates via Kerberos
我开发了一个使用 kerberos 进行身份验证的企业 iOS 应用程序。我对每个请求都有一个 timeoutInterval = 30
。
如果用户在请求超时之前输入密码并通过密码验证,身份验证和 url 请求就可以正常工作。
如果用户在超时后输入密码(iOS 提示用户输入后 30 秒以上),CFNetwork 会在应用程序下次调用 Web 服务时崩溃应用程序,如下所示。
我不确定是什么原因导致了这个问题。
Date/Time: 2017-01-24T03:16:42Z
Launch Time: 2017-01-24T03:16:03Z
OS Version: iPhone OS 10.0.2 (14A456)
Report Version: 104
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0x68
Crashed Thread: 4
Thread 0:
0 libsystem_kernel.dylib 0x0000000189d8816c mach_msg_trap + 8
1 CoreFoundation 0x000000018ad85cec __CFRunLoopServiceMachPort + 188
2 CoreFoundation 0x000000018ad83908 __CFRunLoopRun + 1128
3 CoreFoundation 0x000000018acb2048 CFRunLoopRunSpecific + 440
4 GraphicsServices 0x000000018c735198 GSEventRunModal + 176
5 UIKit 0x0000000190c85628 -[UIApplication _run] + 680
6 UIKit 0x0000000190c80360 UIApplicationMain + 204
7 SampleiOSApp 0x00000001000301bc main (AppDelegate.swift:15)
8 libdyld.dylib 0x0000000189c945b8 start + 0
Thread 1:
0 libsystem_kernel.dylib 0x0000000189da6a88 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000189e68db4 start_wqthread + 0
Thread 2:
0 libsystem_kernel.dylib 0x0000000189da6a88 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000189e68db4 start_wqthread + 0
Thread 3:
0 libsystem_kernel.dylib 0x0000000189d8816c mach_msg_trap + 8
1 CoreFoundation 0x000000018ad85cec __CFRunLoopServiceMachPort + 188
2 CoreFoundation 0x000000018ad83908 __CFRunLoopRun + 1128
3 CoreFoundation 0x000000018acb2048 CFRunLoopRunSpecific + 440
4 Foundation 0x000000018b7c0b1c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300
5 Foundation 0x000000018b7e160c -[NSRunLoop(NSRunLoop) runUntilDate:] + 92
6 UIKit 0x00000001915fac7c -[UIEventFetcher threadMain] + 132
7 Foundation 0x000000018b8be50c __NSThread__start__ + 1020
8 libsystem_pthread.dylib 0x0000000189e6b860 _pthread_body + 236
9 libsystem_pthread.dylib 0x0000000189e6b770 _pthread_start + 280
10 libsystem_pthread.dylib 0x0000000189e68dbc thread_start + 0
Thread 4 Crashed:
0 CFNetwork 0x000000018b51ae60 std::__1::__hash_const_iterator<std::__1::__hash_node<std::__1::__hash_value_type<AuthenticationState::AuthInfoType, std::__1::unique_ptr<AuthenticationInfo, std::__1::default_delete<AuthenticationInfo> > >, void*>*> std::__1::__hash_table<std::__1::__hash_value_type<AuthenticationState::AuthInfoType, std::__1::unique_ptr<AuthenticationInfo, std::__1::default_delete<AuthenticationInfo> > >, std::__1::__unordered_map_hasher<AuthenticationState::AuthInfoType, std::__1::__hash_value_type<AuthenticationState::AuthInfoType, std::__1::unique_ptr<AuthenticationInfo, std::__1::default_delete<AuthenticationInfo> > >, AuthenticationState::AuthInfoTypeHasher, true>, std::__1::__unordered_map_equal<AuthenticationState::AuthInfoType, std::__1::__hash_value_type<AuthenticationState::AuthInfoType, std::__1::unique_ptr<AuthenticationInfo, std::__1::default_delete<AuthenticationInfo> > >, std::__1::equal_to<AuthenticationState::AuthInfoType>, true>, std::__1::allocator<std::__1::__hash_value_type<AuthenticationState::AuthInfoType, std::__1::unique_ptr<AuthenticationInfo, std::__1::default_delete<AuthenticationInfo> > > > >::find<AuthenticationState::AuthInfoType>(AuthenticationState::AuthInfoType const&) const + 0
1 CFNetwork 0x000000018b516b90 AuthenticationState::updateState(HTTPResponseMessage*, _CFURLAuthChallenge*, _CFURLCredential const*, __SecTrust*) + 148
2 CFNetwork 0x000000018b4f8724 HTTPProtocol::_protocolInterface_useCredential(_CFURLCredential const*, _CFURLAuthChallenge*) + 880
3 CFNetwork 0x000000018b4f7008 ___ZN12HTTPProtocol19askAccountsForCredsEh_block_invoke_2 + 240
4 libdispatch.dylib 0x0000000189c611c0 _dispatch_client_callout + 12
5 libdispatch.dylib 0x0000000189c6cb24 _dispatch_block_invoke_direct + 372
6 CFNetwork 0x000000018b5f2e98 RunloopBlockContext::_invoke_block(void const*, void*) + 32
7 CoreFoundation 0x000000018acb19a8 CFArrayApplyFunction + 64
8 CFNetwork 0x000000018b5f2d7c RunloopBlockContext::perform() + 132
9 CFNetwork 0x000000018b5f40a4 MultiplexerSource::perform() + 308
10 CFNetwork 0x000000018b5f3e10 MultiplexerSource::_perform(void*) + 60
11 CoreFoundation 0x000000018ad86278 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 20
12 CoreFoundation 0x000000018ad85bc0 __CFRunLoopDoSources0 + 520
13 CoreFoundation 0x000000018ad837c0 __CFRunLoopRun + 800
14 CoreFoundation 0x000000018acb2048 CFRunLoopRunSpecific + 440
15 CFNetwork 0x000000018b49fcec +[NSURLConnection(Loader) _resourceLoadLoop:] + 332
16 Foundation 0x000000018b8be50c __NSThread__start__ + 1020
17 libsystem_pthread.dylib 0x0000000189e6b860 _pthread_body + 236
18 libsystem_pthread.dylib 0x0000000189e6b770 _pthread_start + 280
19 libsystem_pthread.dylib 0x0000000189e68dbc thread_start + 0
我的请求代码如下:
let manager = Alamofire.SessionManager.default
manager.retrier = RetryingManager()
let request: Alamofire.Request = manager.request(httpRequest as! URLRequestConvertible)
.validate(statusCode: 200..<300)
.validate(contentType: ["application/json"])
.responseObject(queue: queue, completionHandler: {
(response: DataResponse<T>) in
if let JSON = response.result.value {
DispatchQueue.main.async {
debugPrint("JSON: \(JSON)")
// callback with the data
completion(JSON, nil)
}
} else if let resultError = response.result.error {
let errorMessage = WebServerErrorHelper.createErrorMessage(resultError: resultError, statusCode: response.response?.statusCode, serverData: response.data)
DispatchQueue.main.async {
completion(nil, errorMessage)
}
}
})
这里queue
是并发DispatchQueue
,timeInterval
为httpRequest
设置为30。
我不知道如何解决这个问题。提前致谢。
这是 CFNetwork
中的错误,已在 iOS 10.3.3
中修复
我开发了一个使用 kerberos 进行身份验证的企业 iOS 应用程序。我对每个请求都有一个 timeoutInterval = 30
。
如果用户在请求超时之前输入密码并通过密码验证,身份验证和 url 请求就可以正常工作。
如果用户在超时后输入密码(iOS 提示用户输入后 30 秒以上),CFNetwork 会在应用程序下次调用 Web 服务时崩溃应用程序,如下所示。
我不确定是什么原因导致了这个问题。
Date/Time: 2017-01-24T03:16:42Z
Launch Time: 2017-01-24T03:16:03Z
OS Version: iPhone OS 10.0.2 (14A456)
Report Version: 104
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0x68
Crashed Thread: 4
Thread 0:
0 libsystem_kernel.dylib 0x0000000189d8816c mach_msg_trap + 8
1 CoreFoundation 0x000000018ad85cec __CFRunLoopServiceMachPort + 188
2 CoreFoundation 0x000000018ad83908 __CFRunLoopRun + 1128
3 CoreFoundation 0x000000018acb2048 CFRunLoopRunSpecific + 440
4 GraphicsServices 0x000000018c735198 GSEventRunModal + 176
5 UIKit 0x0000000190c85628 -[UIApplication _run] + 680
6 UIKit 0x0000000190c80360 UIApplicationMain + 204
7 SampleiOSApp 0x00000001000301bc main (AppDelegate.swift:15)
8 libdyld.dylib 0x0000000189c945b8 start + 0
Thread 1:
0 libsystem_kernel.dylib 0x0000000189da6a88 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000189e68db4 start_wqthread + 0
Thread 2:
0 libsystem_kernel.dylib 0x0000000189da6a88 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x0000000189e68db4 start_wqthread + 0
Thread 3:
0 libsystem_kernel.dylib 0x0000000189d8816c mach_msg_trap + 8
1 CoreFoundation 0x000000018ad85cec __CFRunLoopServiceMachPort + 188
2 CoreFoundation 0x000000018ad83908 __CFRunLoopRun + 1128
3 CoreFoundation 0x000000018acb2048 CFRunLoopRunSpecific + 440
4 Foundation 0x000000018b7c0b1c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300
5 Foundation 0x000000018b7e160c -[NSRunLoop(NSRunLoop) runUntilDate:] + 92
6 UIKit 0x00000001915fac7c -[UIEventFetcher threadMain] + 132
7 Foundation 0x000000018b8be50c __NSThread__start__ + 1020
8 libsystem_pthread.dylib 0x0000000189e6b860 _pthread_body + 236
9 libsystem_pthread.dylib 0x0000000189e6b770 _pthread_start + 280
10 libsystem_pthread.dylib 0x0000000189e68dbc thread_start + 0
Thread 4 Crashed:
0 CFNetwork 0x000000018b51ae60 std::__1::__hash_const_iterator<std::__1::__hash_node<std::__1::__hash_value_type<AuthenticationState::AuthInfoType, std::__1::unique_ptr<AuthenticationInfo, std::__1::default_delete<AuthenticationInfo> > >, void*>*> std::__1::__hash_table<std::__1::__hash_value_type<AuthenticationState::AuthInfoType, std::__1::unique_ptr<AuthenticationInfo, std::__1::default_delete<AuthenticationInfo> > >, std::__1::__unordered_map_hasher<AuthenticationState::AuthInfoType, std::__1::__hash_value_type<AuthenticationState::AuthInfoType, std::__1::unique_ptr<AuthenticationInfo, std::__1::default_delete<AuthenticationInfo> > >, AuthenticationState::AuthInfoTypeHasher, true>, std::__1::__unordered_map_equal<AuthenticationState::AuthInfoType, std::__1::__hash_value_type<AuthenticationState::AuthInfoType, std::__1::unique_ptr<AuthenticationInfo, std::__1::default_delete<AuthenticationInfo> > >, std::__1::equal_to<AuthenticationState::AuthInfoType>, true>, std::__1::allocator<std::__1::__hash_value_type<AuthenticationState::AuthInfoType, std::__1::unique_ptr<AuthenticationInfo, std::__1::default_delete<AuthenticationInfo> > > > >::find<AuthenticationState::AuthInfoType>(AuthenticationState::AuthInfoType const&) const + 0
1 CFNetwork 0x000000018b516b90 AuthenticationState::updateState(HTTPResponseMessage*, _CFURLAuthChallenge*, _CFURLCredential const*, __SecTrust*) + 148
2 CFNetwork 0x000000018b4f8724 HTTPProtocol::_protocolInterface_useCredential(_CFURLCredential const*, _CFURLAuthChallenge*) + 880
3 CFNetwork 0x000000018b4f7008 ___ZN12HTTPProtocol19askAccountsForCredsEh_block_invoke_2 + 240
4 libdispatch.dylib 0x0000000189c611c0 _dispatch_client_callout + 12
5 libdispatch.dylib 0x0000000189c6cb24 _dispatch_block_invoke_direct + 372
6 CFNetwork 0x000000018b5f2e98 RunloopBlockContext::_invoke_block(void const*, void*) + 32
7 CoreFoundation 0x000000018acb19a8 CFArrayApplyFunction + 64
8 CFNetwork 0x000000018b5f2d7c RunloopBlockContext::perform() + 132
9 CFNetwork 0x000000018b5f40a4 MultiplexerSource::perform() + 308
10 CFNetwork 0x000000018b5f3e10 MultiplexerSource::_perform(void*) + 60
11 CoreFoundation 0x000000018ad86278 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 20
12 CoreFoundation 0x000000018ad85bc0 __CFRunLoopDoSources0 + 520
13 CoreFoundation 0x000000018ad837c0 __CFRunLoopRun + 800
14 CoreFoundation 0x000000018acb2048 CFRunLoopRunSpecific + 440
15 CFNetwork 0x000000018b49fcec +[NSURLConnection(Loader) _resourceLoadLoop:] + 332
16 Foundation 0x000000018b8be50c __NSThread__start__ + 1020
17 libsystem_pthread.dylib 0x0000000189e6b860 _pthread_body + 236
18 libsystem_pthread.dylib 0x0000000189e6b770 _pthread_start + 280
19 libsystem_pthread.dylib 0x0000000189e68dbc thread_start + 0
我的请求代码如下:
let manager = Alamofire.SessionManager.default
manager.retrier = RetryingManager()
let request: Alamofire.Request = manager.request(httpRequest as! URLRequestConvertible)
.validate(statusCode: 200..<300)
.validate(contentType: ["application/json"])
.responseObject(queue: queue, completionHandler: {
(response: DataResponse<T>) in
if let JSON = response.result.value {
DispatchQueue.main.async {
debugPrint("JSON: \(JSON)")
// callback with the data
completion(JSON, nil)
}
} else if let resultError = response.result.error {
let errorMessage = WebServerErrorHelper.createErrorMessage(resultError: resultError, statusCode: response.response?.statusCode, serverData: response.data)
DispatchQueue.main.async {
completion(nil, errorMessage)
}
}
})
这里queue
是并发DispatchQueue
,timeInterval
为httpRequest
设置为30。
我不知道如何解决这个问题。提前致谢。
这是 CFNetwork
中的错误,已在 iOS 10.3.3