Closed thejonjohn closed 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.
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.
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!
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!
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.
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.
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!