2013-05-27 66 views
4

我收到以下錯誤信息:的iOS亞馬遜S3 SDK:發送到釋放實例

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

我不明白,從殭屍檢查堆棧跟蹤得非常好,我不知道這是在告訴我可以修復的任何東西:

# 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:] 

當應用程序上傳照片時會發生此錯誤。照片對象使用和實現下列方法:

-(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請求交談任何其他對象/實例應用程序的唯一點。任何想法是什麼導致這個錯誤?

+0

,你在哪裏調用''-upload你傳遞一個完成塊:您可以通過使用AmazonS3Client的子類,你重寫一個方法,這樣做嗎?如果是這樣,請嘗試傳遞'[block copy]'。 – nielsbot

+0

我也看到了這種情況。任何建議解決方案 – Stavash

+0

我遇到同樣的問題。當來自S3的響應是400時發生這種情況,因爲我使用的臨時憑證已過期。它看起來像AWS SDK中的一個bug,可能只能與S3TransferManager一起使用? –

回答

1

我認爲這是AWS SDK中的一個錯誤。我不確定錯誤的確切位置,但是如果響應是服務異常(並且可能僅與S3TransferManager結合使用),則會由請求重試觸發。

我不想禁用所有重試,所以我通過強制不重試服務異常來解決此問題。 ?

- (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]; 
} 
+0

謝謝你,我們的應用程序使用了一箇舊的AWS開發工具包,這個答案解決了上傳圖像/視頻後出現的異常。 –