首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS亚马逊S3软件开发工具包:向释放的实例发送消息

iOS亚马逊S3软件开发工具包:向释放的实例发送消息
EN

Stack Overflow用户
提问于 2013-05-28 05:19:46
回答 1查看 314关注 0票数 4

我得到以下错误:

代码语言:javascript
复制
*** -[S3PutObjectOperation_Internal respondsToSelector:]: message sent to deallocated instance 0x43c18fd0

我不能很好地理解僵尸检查器的堆栈跟踪,我不确定这是否能告诉我任何我可以修复的东西:

代码语言:javascript
复制
#   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对象使用并实现以下方法:

代码语言:javascript
复制
-(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请求与任何其他对象/实例对话的唯一点。你知道是什么导致了这个错误吗?

EN

回答 1

Stack Overflow用户

发布于 2014-03-25 22:24:07

我认为这是AWS SDK中的一个bug。我不确定bug的确切位置,但如果响应是服务异常(并且可能只与S3TransferManager结合使用),它是由请求重试触发的。

我不想禁用所有重试,因此我通过强制不对服务异常重试来修复此问题。您可以通过使用AmazonS3Client的子类来完成此操作,其中您可以覆盖一个方法,如下所示:

代码语言:javascript
复制
- (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];
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16780677

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档