gpt4 book ai didi

ios - NSURLConnectionLoader 线程中的奇怪崩溃

转载 作者:可可西里 更新时间:2023-11-01 03:35:08 29 4
gpt4 key购买 nike

我们开始看到应用启动时发生的崩溃。我无法重现它,它只发生在少数用户身上。

异常是:异常类型:EXC_BAD_ACCESS 代码:KERN_INVALID_ADDRESS at 0x3250974659

崩溃发生在名为 com.apple.NSURLConnectionLoader 的线程中当调用 -[NSBlockOperation main]

这是该线程的堆栈跟踪:

0    libobjc.A.dylib     objc_msgSend + 91    Foundation      -[NSBlockOperation main] + 2002    Foundation  -[__NSOperationInternal start] + 8403    Foundation  -[_NSCFURLProtocolBridgeWithTrampoline processEventQ] + 3444    Foundation  -[_NSCFURLProtocolBridgeWithTrampoline pushEvent:from:] + 2985    Foundation  -[_NSCFURLProtocolBridge stop] + 886    Foundation  _bridger + 647    CFNetwork   __block_global_7 + 248    CFNetwork   __block_global_8 + 129    CFNetwork   ___performAsync_block_invoke_068 + 1810   CoreFoundation  CFArrayApplyFunction + 17611   CFNetwork   RunloopBlockContext::perform() + 7412   CFNetwork   MultiplexerSource::perform() + 18813   CoreFoundation  __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 1414   CoreFoundation  __CFRunLoopDoSources0 + 21215   CoreFoundation  __CFRunLoopRun + 64616   CoreFoundation  CFRunLoopRunSpecific + 35617   CoreFoundation  CFRunLoopRunInMode + 10418   Foundation  +[NSURLConnection(Loader) _resourceLoadLoop:] + 30819   Foundation  __NSThread__main__ + 97220   libsystem_c.dylib   _pthread_start + 308

如果能帮助您了解是什么导致了这种崩溃,我们将不胜感激。

最佳答案

对我而言,这段代码间接导致了崩溃。如果我正确阅读故障转储

[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]

正在触发 NSURLConnectionLoaderThread。这可能是他们用于异步支持的内容。但是当我使用同步请求时,我无法在线程运行时释放对象。如果你问我,那是 IOS 7 中的一个错误。

NSMutableURLRequest* request = [self setupRequestWithService:service andMethod:operation];

[request addValue:CONTENT_TYPE_APPLICATION_JSON forHTTPHeaderField:REQUEST_HEADER_CONTENT_TYPE];
[request setHTTPMethod:@"POST"];

NSError* error = nil;
NSData* jsonData = nil;

NSAssert(message,@"Message must not be null");

jsonData = [NSJSONSerialization dataWithJSONObject:[message toDictionary] options:kNilOptions error:&error];

NSAssert(! error, @"Message could not be json serialized");

Log(@"----------------------------------------------------------------------");
Log(@"JSON DATA: - %@", [[NSString alloc] initWithData:jsonData
encoding:NSUTF8StringEncoding]);
Log(@"----------------------------------------------------------------------");

[request setHTTPBody:jsonData];

// Send Synchronous Request
NSURLResponse *response = nil;
error = nil;
NSData* responseData = nil;
NSString* responseString = nil;

responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

关于ios - NSURLConnectionLoader 线程中的奇怪崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18698647/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com