vgmoose / OpenBackupExtractor

A free program for extracting data (like voicemails) from iPhone and iPad backups.
GNU General Public License v3.0
159 stars 25 forks source link

crash near end of extraction #3

Closed thejonjohn closed 5 years ago

thejonjohn commented 5 years ago

First off, thank you for creating this! Very useful.

This report is for release v1.1. I get a consistent crash near the end of extraction every time I run it. I've tried extracting everything, and also selecting only Photos and Videos (same result). Hopefully in the next few days I'll have time to make a debug build and get more info about the crash since I doubt you can reproduce it without my iphone backup, but in the meantime I just wanted to let you know about the issue and provide the following basic crash report. Without looking at any source code yet I'm guessing a corrupted function pointer or something of the like since it's executing an illegal instruction. Thanks!

Process:               Open Backup Extractor [61158]
Path:                  /Applications/Open Backup Extractor.app/Contents/MacOS/Open Backup Extractor
Identifier:            com.vgmoose.Open-Backup-Extractor
Version:               1.1 (1)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Open Backup Extractor [61158]
User ID:               501

Date/Time:             2018-12-04 22:31:15.578 -0600
OS Version:            Mac OS X 10.13.6 (17G3025)
Report Version:        12
Anonymous UUID:        1A5BB5D4-A81B-9AC6-3FEE-04D69E8EA6A6

Sleep/Wake UUID:       5E832DFF-479E-435D-A757-5A19A7415686

Time Awake Since Boot: 79000 seconds
Time Since Wake:       8700 seconds

System Integrity Protection: enabled

Crashed Thread:        2  Dispatch queue: com.apple.root.utility-qos

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Illegal instruction: 4
Termination Reason:    Namespace SIGNAL, Code 0x4
Terminating Process:   exc handler [0]

Thread 0:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff6ee0e20a mach_msg_trap + 10
1   libsystem_kernel.dylib          0x00007fff6ee0d724 mach_msg + 60
2   com.apple.CoreFoundation        0x00007fff46cfeea5 __CFRunLoopServiceMachPort + 341
3   com.apple.CoreFoundation        0x00007fff46cfe1f7 __CFRunLoopRun + 1783
4   com.apple.CoreFoundation        0x00007fff46cfd867 CFRunLoopRunSpecific + 487
5   com.apple.HIToolbox             0x00007fff45fddd96 RunCurrentEventLoopInMode + 286
6   com.apple.HIToolbox             0x00007fff45fddb06 ReceiveNextEventCommon + 613
7   com.apple.HIToolbox             0x00007fff45fdd884 _BlockUntilNextEventMatchingListInModeWithFilter + 64
8   com.apple.AppKit                0x00007fff4428da73 _DPSNextEvent + 2085
9   com.apple.AppKit                0x00007fff44a23e34 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
10  com.apple.AppKit                0x00007fff44282885 -[NSApplication run] + 764
11  com.apple.AppKit                0x00007fff44251a72 NSApplicationMain + 804
12  com.vgmoose.Open-Backup-Extractor   0x0000000104e1e969 0x104e1d000 + 6505
13  libdyld.dylib                   0x00007fff6ecc7015 start + 1

Thread 1:: com.apple.NSEventThread
0   libsystem_kernel.dylib          0x00007fff6ee0e20a mach_msg_trap + 10
1   libsystem_kernel.dylib          0x00007fff6ee0d724 mach_msg + 60
2   com.apple.CoreFoundation        0x00007fff46cfeea5 __CFRunLoopServiceMachPort + 341
3   com.apple.CoreFoundation        0x00007fff46cfe1f7 __CFRunLoopRun + 1783
4   com.apple.CoreFoundation        0x00007fff46cfd867 CFRunLoopRunSpecific + 487
5   com.apple.AppKit                0x00007fff443cafc4 _NSEventThread + 184
6   libsystem_pthread.dylib         0x00007fff6efdf661 _pthread_body + 340
7   libsystem_pthread.dylib         0x00007fff6efdf50d _pthread_start + 377
8   libsystem_pthread.dylib         0x00007fff6efdebf9 thread_start + 13

Thread 2 Crashed:: Dispatch queue: com.apple.root.utility-qos
0   com.vgmoose.Open-Backup-Extractor   0x0000000104e24f4b 0x104e1d000 + 32587
1   com.vgmoose.Open-Backup-Extractor   0x0000000104e2572c 0x104e1d000 + 34604
2   com.vgmoose.Open-Backup-Extractor   0x0000000104e20ff0 0x104e1d000 + 16368
3   libdispatch.dylib               0x00007fff6ec955fa _dispatch_call_block_and_release + 12
4   libdispatch.dylib               0x00007fff6ec8ddb8 _dispatch_client_callout + 8
5   libdispatch.dylib               0x00007fff6ec8fb2c _dispatch_root_queue_drain + 902
6   libdispatch.dylib               0x00007fff6ec8f755 _dispatch_worker_thread3 + 101
7   libsystem_pthread.dylib         0x00007fff6efdf169 _pthread_wqthread + 1387
8   libsystem_pthread.dylib         0x00007fff6efdebe9 start_wqthread + 13

Thread 3:
0   libsystem_pthread.dylib         0x00007fff6efdebdc start_wqthread + 0

Thread 4:
0   libsystem_kernel.dylib          0x00007fff6ee1828a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff6efdf009 _pthread_wqthread + 1035
2   libsystem_pthread.dylib         0x00007fff6efdebe9 start_wqthread + 13

Thread 2 crashed with X86 Thread State (64-bit):
  rax: 0x0000600000369fc0  rbx: 0x0000000000000000  rcx: 0x0000000000008707  rdx: 0x0000000000008706
  rdi: 0x0000000105956580  rsi: 0x0000000000000008  rbp: 0x000070000bf6ada0  rsp: 0x000070000bf6abd0
   r8: 0x0000000000000003   r9: 0x0000600000369b40  r10: 0x000060000047fd50  r11: 0x0000000000000202
  r12: 0x0000600000369b40  r13: 0x00007fd467d82d20  r14: 0x0000604000e7e800  r15: 0x00007fd467d82d00
  rip: 0x0000000104e24f4b  rfl: 0x0000000000010246  cr2: 0x000000010ef9d000

Logical CPU:     2
Error Code:      0x00000000
Trap Number:     6
vgmoose commented 5 years ago

Thanks! I wonder if this problem is this issue, since my compiled release might not have included/referenced libmagic in a portable form.

Did it export any files at all to the target folder, or the bar moves and no files are written?

Would also be interested in seeing how it runs if you compile it yourself. If there are issues compiling let me know as i haven’t done it in a while.

thejonjohn commented 5 years ago

So I got it compiling and running and reproduced the error in a debug build. The problem seems to be in lines 272-273 of ViewController.swift:

                            let magic_full = magic_file(magic_cookie, unsortedFilePath);
                            let type = String.init(cString: magic_full!)

I get this error on line 273: Thread 15: Fatal error: Unexpectedly found nil while unwrapping an Optional value

I believe this means that the magic_file function is returning nil and that case is not handled. It does export many files to the target folder and the bar moves almost to the end before this happens.

thejonjohn commented 5 years ago

Well I made a change to ignore NULL magic_file results and that seems to have fixed the issue. Apparently there is some type of file in my backup that causes libmagic to have an error:

The magic_file() function returns a textual description of the contents of the filename argument, or NULL if an error occurred. If the filename is NULL, then stdin is used.

I'm just looking for images and video so I assume I'm not skipping anything important for me this way. Thanks again for creating this tool!

vgmoose commented 5 years ago

Oh, interesting. Would you be able to find the type of file that is returning null, out of curiosity? (maybe by printing file names before the crash)

Would also be interested in a PR with the null check, if you’re willing!

thejonjohn commented 5 years ago

I did some debugging and found that there are 3 files in my backup for which the magic_file function returns NULL. All 3 are jpegs. Two of them are identical so I really only have 2 unique examples. So I guess libmagic isn't always able to recognize a jpeg without error.

vgmoose commented 5 years ago

Huh, that's too bad. It would be nice to not to miss those files if they are actually valid JPEGs, but if libmagic can't tell what they are I'm not sure what else we could do.