2015-04-05 71 views
2

由於某種原因,我的應用程序崩潰了,而且我不確定是什麼原因導致問題,除了它似乎與處理文件時出現的分派隊列有關。任何幫助將不勝感激。線程錯誤BAD_ACCESS(SIGSEGV)

Crashed Thread: 0 Dispatch queue: com.apple.main-thread 

Exception Type: EXC_BAD_ACCESS (SIGSEGV) 
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000038 

VM Regions Near 0x38: 
--> 
    __TEXT     00000001018e7000-000000010190b000 [ 144K] r-x/rwx SM=COW /Users/USER/Desktop/MaviÃÅ 10.8 Build.app/Contents/MacOS/MaviÃÅ 

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 
0 libdispatch.dylib    0x00007fff8c83dc28 dispatch_async_f + 3 
1 com.larod.mavi     0x00000001018f6e12 0x1018e7000 + 65042 
2 com.apple.AppKit    0x00007fff890df99e -[NSTableView performDragOperation:] + 215 
3 com.apple.AppKit    0x00007fff88f2c94f NSCoreDragReceiveMessageProc + 1651 
4 com.apple.HIServices   0x00007fff8a8f046a DoMultipartDropMessage + 301 
5 com.apple.HIServices   0x00007fff8a8f0135 DoDropMessage + 49 
6 com.apple.HIServices   0x00007fff8a8f0c5e CoreDragMessageHandler + 1543 
7 com.apple.CoreFoundation  0x00007fff89ca858d __CFMessagePortPerform + 701 
8 com.apple.CoreFoundation  0x00007fff89bbcd09 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41 
9 com.apple.CoreFoundation  0x00007fff89bbca49 __CFRunLoopDoSource1 + 153 
10 com.apple.CoreFoundation  0x00007fff89befc02 __CFRunLoopRun + 1826 
11 com.apple.CoreFoundation  0x00007fff89bef0e2 CFRunLoopRunSpecific + 290 
12 com.apple.HIToolbox    0x00007fff8871beb4 RunCurrentEventLoopInMode + 209 
13 com.apple.HIToolbox    0x00007fff8871bc52 ReceiveNextEventCommon + 356 
14 com.apple.HIToolbox    0x00007fff8871bae3 BlockUntilNextEventMatchingListInMode + 62 
15 com.apple.AppKit    0x00007fff88bdb533 _DPSNextEvent + 685 
16 com.apple.AppKit    0x00007fff88bdadf2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128 
17 com.apple.AppKit    0x00007fff88bd21a3 -[NSApplication run] + 517 
18 com.apple.AppKit    0x00007fff88b76bd6 NSApplicationMain + 869 
19 libdyld.dylib     0x00007fff85ff97e1 start + 1 

Thread 1: 
0 libsystem_kernel.dylib   0x00007fff8404a6d6 __workq_kernreturn + 10 
1 libsystem_c.dylib    0x00007fff8c8bdf1c _pthread_workq_return + 25 
2 libsystem_c.dylib    0x00007fff8c8bdce3 _pthread_wqthread + 412 
3 libsystem_c.dylib    0x00007fff8c8a8191 start_wqthread + 13 

Thread 2:: Dispatch queue: com.apple.libdispatch-manager 
0 libsystem_kernel.dylib   0x00007fff8404ad16 kevent + 10 
1 libdispatch.dylib    0x00007fff8c83fdea _dispatch_mgr_invoke + 883 
2 libdispatch.dylib    0x00007fff8c83f9ee _dispatch_mgr_thread + 54 

Thread 3:: CVDisplayLink 
0 libsystem_kernel.dylib   0x00007fff8404a0fa __psynch_cvwait + 10 
1 libsystem_c.dylib    0x00007fff8c8bffb9 _pthread_cond_wait + 869 
2 com.apple.CoreVideo    0x00007fff8761b2a1 CVDisplayLink::runIOThread() + 689 
3 com.apple.CoreVideo    0x00007fff8761afd7 startIOThread(void*) + 148 
4 libsystem_c.dylib    0x00007fff8c8bb772 _pthread_start + 327 
5 libsystem_c.dylib    0x00007fff8c8a81a1 thread_start + 13 

Thread 0 crashed with X86 Thread State (64-bit): 
    rax: 0x00007fc1a0434f90 rbx: 0x0000000000000000 rcx: 0xffff803e5fbcafaf rdx: 0x00007fff8c840ef2 
    rdi: 0x0000000000000000 rsi: 0x00007fc1a0434f90 rbp: 0x00007fff5e317000 rsp: 0x00007fff5e316f58 
    r8: 0xffff803e5fbcafaf r9: 0x00000000000000ff r10: 0x00007fc1a100ec00 r11: 0x0000000005d414ad 
    r12: 0x00007fff8602d360 r13: 0x00007fc1a0435050 r14: 0x00007fc1a0435050 r15: 0x00007fff8602df50 
    rip: 0x00007fff8c83dc28 rfl: 0x0000000000010206 cr2: 0x0000000000000038 
Logical CPU: 0 

External Modification Summary: 
    Calls made by other processes targeting this process: 
    task_for_pid: 2 
    thread_create: 0 
    thread_set_state: 0 
    Calls made by this process: 
    task_for_pid: 0 
    thread_create: 0 
    thread_set_state: 0 
    Calls made by all processes on this machine: 
    task_for_pid: 28757 
    thread_create: 0 
    thread_set_state: 0 

VM Region Summary: 
ReadOnly portion of Libraries: Total=187.9M resident=78.8M(42%) swapped_out_or_unallocated=109.1M(58%) 
Writable regions: Total=155.6M written=3596K(2%) resident=14.4M(9%) swapped_out=0K(0%) unallocated=141.2M(91%) 

REGION TYPE      VIRTUAL 
===========      ======= 
CG backing stores     2280K 
CG image        4K 
CG raster data      56K 
CG shared images     1184K 
CoreAnimation      44K 
CoreImage        4K 
CoreServices      1724K 
IOKit        4476K 
IOKit (reserved)      4K  reserved VM address space (unallocated) 
MALLOC       114.6M 
MALLOC guard page     48K 
Memory tag=240      4K 
Memory tag=242      12K 
Memory tag=251      8K 
OpenCL        8K 
OpenGL GLSL      1936K 
OpenGL GLSL (reserved)    128K  reserved VM address space (unallocated) 
SQLite page cache     96K 
STACK GUARD      56.0M 
Stack        9752K 
VM_ALLOCATE      16.2M 
__DATA        37.2M 
__IMAGE        528K 
__LINKEDIT       54.5M 
__TEXT       133.4M 
__UNICODE       544K 
mapped file      41.9M 
shared memory      372K 
===========      ======= 
TOTAL        476.4M 
TOTAL, minus reserved VM space 476.3M 

這是我認爲崩潰應用程序的實際代碼。

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{ 
     unsigned long __block current = 0; 
     unsigned long total = 0; 

     dispatch_sync(dispatch_get_main_queue(), ^{ 
      _fileOperation = YES; 
      [_fileCopyProgress setHidden:NO]; 
      [_fileCopyProgress startAnimation:self]; 
      [_processString setStringValue:@"Scanning..."]; 
      [_processString setHidden:NO]; 
     }); 

     for (NSURL* url in pboardObjects) { 
      [self scanFileURLSForImport:url]; 
     } 

     total = _mediaFileURLSForImport.count; 
     [self updateImportProcess:current of:total]; 

     [_processString setStringValue:@"Importing..."]; 

     for (NSURL* url in _mediaFileURLSForImport) { 
      [self performSelectorOnMainThread:@selector(createVideo_2:) withObject:url waitUntilDone:YES]; 
      [self updateImportProcess:(++current) of:total]; 
     } 

     [self performSelectorOnMainThread:@selector(saveAction:) withObject:nil waitUntilDone:YES]; 
     [_tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES]; 
     [self performSelectorOnMainThread:@selector(selectImportedFiles:) withObject:nil waitUntilDone:YES]; 

     dispatch_sync(dispatch_get_main_queue(), ^{ 
      _fileOperation = NO; 
      [_processString setStringValue:@""]; 
      [_processString setHidden:YES]; 
      [_fileCopyProgress setHidden:YES]; 
      [_fileCopyProgress stopAnimation:self]; 
     }); 
    }); 

要添加有點扭曲的,這種碰撞不會對我的測試機發生的一切完美地運行在那裏,應用程序提交到應用商店,並得到蘋果的批准,這意味着在這兩個測試常規和來賓帳戶。但昨天它每次都在同事機器上墜毀。我必須試圖解決它的唯一問題是他的機器上的這個報告。我無法在我的測試機器上覆制這個,所有東西都可以在那裏工作。

回答

2

Symbolicate您的崩潰報告。之後你會看到你的代碼在崩潰中涉及的部分堆棧。

1 com.larod.mavi     0x00000001018f6e12 0x1018e7000 + 65042 
0

掛鉤lldb並設置異常斷點以破壞崩潰的位置,並通過lldb中的bt命令檢查堆棧跟蹤。通常情況下,通過寫入只能讀取的內存來獲得內存崩潰,或者正在訪問被釋放的對象。從日誌中,我假設你拖動Views並執行某些操作,你確定相關視圖在塊中仍然有效嗎?所有的意見應該在主線程上,仍然在內存中有效

+0

要添加一點扭曲,這個崩潰不會發生在我的測試機器上,所有的一切都運行完美,應用程序已提交到應用商店,並通過蘋果,這意味着它在常規和來賓帳戶中都經過了測試。但昨天它每次都在同事機器上墜毀。我必須試圖解決它的唯一問題是他的機器上的這個報告。我無法在我的測試機器上覆制這個,所有東西都可以在那裏工作。 – larod 2015-04-05 17:32:26

+0

在其他機器上會發生這種情況,機器型號和操作系統版本是什麼?嘗試使用相同的型號和操作系統版本,或者你可以借用機器進行調試? – Wingzero 2015-04-05 23:12:47

+0

實際上是一臺新機器,他有一個mac pro,更新的型號,我在macbook pro上做我的開發工具,我的測試機器是mac mini。我會再次嘗試下個週末,這個bug非常不尋常。如果沒有他的機器,很難象徵,但我會盡我所能。 – larod 2015-04-06 00:28:49