2011-10-12 3 views
1

우리는 SIGBUS (BUS_ADRALN)을 얻었고이 스레드를 가리 킵니다. 이 오류의 원인은 무엇입니까? 68 행 중 하나입니다 NSString * dateString = [dateFormat stringFromDate : currentTimestamp]; 또는 [dateFormat release];SIGBUS의 원인은 무엇입니까?

NSDate *currentTimestamp = self.timestamp; 

if (!currentTimestamp) 
    return nil; // sanity check 

[currentTimestamp retain]; 

NSDateComponents *otherDay = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:currentTimestamp]; 
NSDateComponents *today = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:[NSDate date]]; 
NSDateComponents *yesterday = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:[[NSDate date] addTimeInterval: -24 * 60 * 60]]; 

if ([today day] == [otherDay day] && 
    [today month] == [otherDay month] && 
    [today year] == [otherDay year]) { 

    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; 
    [dateFormat setDateFormat:@"h:mm a"]; 
    NSString *dateString = [dateFormat stringFromDate:currentTimestamp]; 
    [dateFormat release]; 
    [currentTimestamp release]; 
    return [NSString stringWithFormat:@"Today %@", dateString]; 
} 
else if ([yesterday day] == [otherDay day] && 
     [yesterday month] == [otherDay month] && 
     [yesterday year] == [otherDay year]) { 

    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; 
    [dateFormat setDateFormat:@"h:mm a"]; 
    NSString *dateString = [dateFormat stringFromDate:currentTimestamp]; 
    [dateFormat release]; 
    [currentTimestamp release]; 
    return [NSString stringWithFormat:@"Yesterday %@", dateString]; 
} 

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; 
[dateFormat setDateFormat:@"MM/dd/yyyy h:mm a"]; 

// below is line 68 
NSString *dateString = [dateFormat stringFromDate:currentTimestamp]; 
[dateFormat release]; 
[currentTimestamp release]; 

return dateString; 

0 CoreFoundation      0x33474894 CFDateFormatterCreateStringWithAbsoluteTime + 60 
1 CoreFoundation      0x33474817 CFDateFormatterCreateStringWithDate + 31 
2 Foundation       0x326c4ad7 -[NSDateFormatter stringForObjectValue:] + 91 
3 Foundation       0x326c4a75 -[NSDateFormatter stringFromDate:] + 21 
4 MyApp        0x000a81dc -[Message getFormattedTimestamp] (Message.m:68) 
5 MyApp        0x0007b7a4 -[ConversationView newBubble:withFrame:] (ConversationView.m:452) 
6 MyApp        0x0007b2fc -[ConversationView tableView:heightForRowAtIndexPath:] (ConversationView.m:520) 
7 UIKit        0x31bb3b09 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 2173 
8 UIKit        0x31bb3225 -[UITableViewRowData numberOfRows] + 73 
9 UIKit        0x31bb2c73 -[UITableView noteNumberOfRowsChanged] + 83 
10 UIKit        0x31bb27f7 -[UITableView reloadData] + 583 
11 MyApp        0x0007cccc -[ConversationView reloadAndMoveToEnd:] (ConversationView.m:147) 
12 MyApp        0x0007cc6c -[ConversationView managedObjectContext:fetchCompletedForRequest:withResults:error:] (ConversationView.m:153) 
13 MyApp        0x00197670 -[IZManagedObjectContext backgroundFetchOperation:completedWithIDs:error:] (IZManagedObjectContext.m:150) 
14 MyApp        0x001970b0 -[IZBackgroundFetchOperation fetchRequestDidCompleteWithUserInfo:] (IZBackgroundFetchOperation.m:108) 
15 CoreFoundation      0x3347df03 -[NSObject(NSObject) performSelector:withObject:] + 23 
16 Foundation       0x327237a9 __NSThreadPerformPerform + 269 
17 CoreFoundation      0x334e7a79 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 13 
18 CoreFoundation      0x334e975f __CFRunLoopDoSources0 + 383 
19 CoreFoundation      0x334ea4eb __CFRunLoopRun + 231 
20 CoreFoundation      0x3347aec3 CFRunLoopRunSpecific + 231 
21 CoreFoundation      0x3347adcb CFRunLoopRunInMode + 59 
22 GraphicsServices     0x311a541f GSEventRunModal + 115 
23 GraphicsServices     0x311a54cb GSEventRun + 63 
24 UIKit        0x31b90d69 -[UIApplication _run] + 405 
25 UIKit        0x31b8e807 UIApplicationMain + 671 
26 MyApp        0x0009b578 main (main.m:5) 
+0

오류 로그를 게시하십시오. – zaph

+0

스레드 크래시가 실제 코드 아래에 있습니다. 모든 스레드를보고 싶습니까? 감사! – tjg184

+0

충돌에 대한 다른 메시지가 없습니까? 다음 중 NSString * dateString = [dateFormat stringFromDate : currentTimestamp];가 세 줄 중 어느 것입니까? – zaph

답변

0

위 코드는 단원 테스트를 작성한 결과입니다. 그것이 메모리 문제였던 것으로 밝혀졌습니다. 이상한 일은 항상이 줄을 지적합니다.

+0

자세한 내용을 추가 할 수 있습니까? – scorpiodawg

+0

위의 코드는 문제가 없습니다. 실제로이 문제를 일으킨 코드의 완전히 다른 부분에서 메모리 문제였습니다. 이와 비슷한 것을 보았다면 Instruments를 사용하여 메모리 문제를 확인하는 것이 좋습니다. 뿌리 문제를 파악하기 위해 최소한의 말을하는 것은 고통 스러웠습니다. 희망이 도움이됩니다. – tjg184

+0

동일한 오류가 발생했습니다 : BUS_ADRALN (SIGBUS). 악기를 찾아내는 방법을 알려주십시오. – Mrunal

관련 문제