4

我收到以下错误:

*** -[S3PutObjectOperation_Internal respondsToSelector:]: message sent to deallocated instance 0x43c18fd0

我不太了解 Zombies 检查员的堆栈跟踪,我不确定这是否告诉我我可以解决的任何问题:

#   Address Category    Event Type  RefCt   Timestamp   Size    Responsible Library Responsible Caller
0   0xc071f60   S3PutObjectOperation_Internal   Malloc  1   00:14.903.021   48  MyApp   -[S3TransferManager upload:]
1   0xc071f60   S3PutObjectOperation_Internal   Retain  2   00:14.903.032   0   Foundation  ____addOperations_block_invoke_0
2   0xc071f60   S3PutObjectOperation_Internal   Release 1   00:14.903.036   0   MyApp   -[S3TransferManager upload:]
3   0xc071f60   S3PutObjectOperation_Internal   Retain  2   00:14.904.154   0   libsystem_sim_blocks.dylib  _Block_object_assign
4   0xc071f60   S3PutObjectOperation_Internal   Retain  3   00:14.904.163   0   libsystem_sim_blocks.dylib  _Block_object_assign
5   0xc071f60   S3PutObjectOperation_Internal   Release 2   00:14.904.164   0   Foundation  __destroy_helper_block_474
6   0xc071f60   S3PutObjectOperation_Internal   Retain  3   00:14.906.549   0   MyApp   -[S3PutObjectOperation_Internal start]
7   0xc071f60   S3PutObjectOperation_Internal   Release 2   00:14.906.554   0   MyApp   -[S3PutObjectOperation_Internal start]
8   0xc071f60   S3PutObjectOperation_Internal   Release 1   00:14.907.624   0   MyApp   __destroy_helper_block_
9   0xc071f60   S3PutObjectOperation_Internal   Retain  2   00:15.243.299   0   MyApp   -[S3PutObjectOperation_Internal finish]
10  0xc071f60   S3PutObjectOperation_Internal   Retain  3   00:15.243.302   0   MyApp   -[S3PutObjectOperation_Internal finish]
11  0xc071f60   S3PutObjectOperation_Internal   Release 2   00:15.243.307   0   MyApp   -[S3PutObjectOperation_Internal finish]
12  0xc071f60   S3PutObjectOperation_Internal   Release 1   00:15.243.330   0   MyApp   -[S3PutObjectOperation_Internal finish]
13  0xc071f60   S3PutObjectOperation_Internal   Release 0   00:15.244.420   0   Foundation  __release_object_op
14  0xc071f60   S3PutObjectOperation_Internal   Zombie  -1  00:15.386.107   0   MyApp   -[S3Response connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:]

当应用程序上传照片时会发生此错误。Photo 对象使用并实现以下方法:

-(void)request:(AmazonServiceRequest *)request didSendData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
  NSLog(@"didSendData called: %d - %d / %d", bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
  self.transferProgress += bytesWritten;
  float p = (float) self.transferProgress / self.uploadSize;
  self.uploadProgress = [NSNumber numberWithFloat:p];
}

-(void)request:(AmazonServiceRequest *)request didCompleteWithResponse:(AmazonServiceResponse *)response
{
  NSLog(@"didCompleteWithResponse called.");
}

-(void)request:(AmazonServiceRequest *)request didFailWithError:(NSError *)error
{
  NSLog(@"didFailWithError called: %@", error);
}

据我所知,这是应用程序中 S3 请求与任何其他对象/实例对话的唯一点。知道是什么导致了这个错误吗?

4

1 回答 1

1

我认为这是 AWS SDK 中的一个错误。我不确定错误到底在哪里,但如果响应是服务异常(并且可能仅与 S3TransferManager 一起使用),它会由请求重试触发。

我不想禁用所有重试,所以我通过强制不重试服务异常来解决这个问题。您可以通过使用 AmazonS3Client 的子类来执行此操作,您可以在其中覆盖一个方法,如下所示:

- (BOOL)shouldRetry:(AmazonServiceResponse *)response exception:(NSException *)exception
{
    // There is some kind of bug that is triggered on request retries when S3 requests
    // return an explicit service exception (e.g., auth token expired). In these cases
    // we force no retry to avoid the bug.
    NSException *exceptionHolder = response.exception;
    if(exceptionHolder == nil)
    {
        exceptionHolder = exception;
    }

    if([exceptionHolder isKindOfClass:[AmazonServiceException class]])
    {
        return NO;
    }

    return [super shouldRetry:response exception:exception];
}
于 2014-03-25T14:24:07.237 回答