2013-02-28 78 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