2013-02-28 125 views
0

我試圖測試我的Mac OS應用程序,它在10.8上運行良好,但是當我開始在Mac 10.6.3(iatkos s3)上測試時,出現了一些問題。performSelectorInBackground:在Mac OS上立即崩潰x 10.6.3

首先,我必須使用單獨的計算機來安裝10.6.3,因爲我的MacBook Air不允許我安裝10.6.3(硬件比軟件更新)。我所做的是,在xcode中運行它,獲取.app文件,將它放到我的10.6.3應用程序文件夾中,然後運行它。

我把一些跟蹤日誌那裏,這裏是我的代碼:

- (void) startMethodInBackground: (id) sender { 
    NSLog(@"line 101"); //this shows 
    [self performSelectorInBackground:@selector(myOtherMethod:) withObject:sender]; 
    NSLog(@"line 102"); //not showing 
} 

- (void) myOtherMethod: (id) sender { 
    NSLog(@"line 201"); //not showing 
    @autoreleasepool { 
     NSLog(@"line 202"); //again not showing 
     @synchronized (self) { 
      NSLog(@"line 203"); //not showing 
      ... ... 
     } 
    } 
} 



Version:   1.0 (1) 
Code Type:  X86-64 (Native) 
Parent Process: launchd [1126] 

Date/Time:  2013-02-28 16:53:10.668 -0500 
OS Version:  Mac OS X 10.6.3 (10D573) 
Report Version: 6 

Exception Type: EXC_BAD_ACCESS (SIGSEGV) 
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000 
Crashed Thread: 2 
... (too long so I trimmed it) 
... 
    Thread 2 Crashed: 
0 ???        000000000000000000 0 + 0 
1 com.apple.Foundation   0x00007fff814e4ead __NSThread__main__ + 1429 
2 libSystem.B.dylib    0x00007fff86db38b6 _pthread_start + 331 
3 libSystem.B.dylib    0x00007fff86db3769 thread_start + 13 

Thread 2 crashed with X86 Thread State (64-bit): 
    rax: 0x0000000000000000 rbx: 0x0000000100863400 rcx: 0x0000000000000000 rdx: 0x00000001001417b0 
    rdi: 0x00000001001417b0 rsi: 0x0000000000000000 rbp: 0x0000000100480c90 rsp: 0x0000000100480b08 
    r8: 0x0000000000000000 r9: 0x0000000100201530 r10: 0x0000000100210870 r11: 0x0000000100002120 
    r12: 0x00007fff5fbfe800 r13: 0x0000000000001b07 r14: 0x00007fff814e4918 r15: 0x0000000102e0ec20 
    rip: 0x0000000000000000 rfl: 0x0000000000010202 cr2: 0x0000000000000000 

,你可以在我的代碼,只要我打電話myOtherMethod看到,:使用performSelectorInBackground :,墜毀!

所以我的問題是:

  1. 任何理由調用performSelectorInBackground崩潰?我檢查了performSelectorInBackground方法,它應該在10.6(蘋果文檔說10.5或更高版本)上正常工作,所以我真的必須發生什麼事情!

  2. 崩潰報告對我來說真的沒有意義,所以在現實生活中,你怎麼能用這樣的報告進行調試?在Xcode中,如果有任何問題,它會崩潰,並會告訴我哪種方法導致了問題和問題,但正如您所看到的,崩潰報告沒有告訴我太多!

任何幫助表示讚賞。 Josh

+0

是否有可能您的對象被釋放? – paulmelnikow 2013-03-14 06:17:29

回答

0

它看起來像一個腐敗的堆棧。

你可能在myOtherMethod中分配了大量的內存,就像一個大C數組一樣嗎?在主線程上調用myOtherMethod會發生什麼?

+0

它與內存分配無關。我創建了一個虛擬應用程序,使用performSelectorsInBackground:調用一個虛擬方法,在這個虛擬方法中,我有@ autoreleasepool然後@ synchronized(self),除此之外沒有別的,但有一些簡單的痕跡。如果我拿出@ synchronized,它不會崩潰,如果我把@synchronized,它會崩潰。我使用synchronized的原因是,我想確保沒有多個線程同時運行myOtherMethod,如果線程1正在運行myOtherMethod,線程2應該等到線程1完成。但爲什麼它同步墜毀在10.6但不是10.8? – Josh 2013-02-28 23:10:44