sgan81 / apfs-fuse

FUSE driver for APFS (Apple File System)
GNU General Public License v2.0
1.8k stars 163 forks source link

Segmentation fault when reading from the mounted apfs-fuse filsystem #75

Open federunix opened 5 years ago

federunix commented 5 years ago

I am recovering the content of my /Users directory from a boot disk with APFS from an old iMac 2011 that died. I mounted the disk on a Linux workstation and when I try to make a tar archive of a specific folder apfs-fuse with a segmentation fault.

I can reproduce 100% if I try to tar this specific folder.

./apfs-fuse -d 3 /dev/sda2 /tmp/federiMac

.... apfs_lookup: ino=2fa4c25 name=roma1.gif => OK apfs_stat_internal => OK apfs_open: 2fa4c2a apfs_read: ino=2fa4c2a size=4000 off=0 apfs_release 2fa4c2a apfs_lookup: ino=2fa4c25 name=aosta1.gif => OK apfs_stat_internal => OK apfs_open: 2fa4c26 apfs_read: ino=2fa4c26 size=4000 off=0 apfs_read: ino=2fa4c26 size=1000 off=4000 apfs_release 2fa4c26 apfs_lookup: ino=2fa4c25 name=head2cg.gif => OK apfs_stat_internal => OK apfs_open: 2fa4c27 apfs_read: ino=2fa4c27 size=3000 off=0 apfs_release 2fa4c27 apfs_releasedir 2fa4c25 apfs_releasedir 2fa4c23 apfs_lookup: ino=2fa3ece name=.DS_Store => OK apfs_stat_internal => OK apfs_open: 2fa4d40 apfs_read: ino=2fa4d40 size=2000 off=0 apfs_release 2fa4d40 apfs_lookup: ino=2fa3ece name=cucina internazionale => OK apfs_stat_internal => OK apfs_opendir: 2fa3ecf apfs_readdir: 2fa3ecf Segmentation fault (core dumped) ....

gdb ./apfs-fuse core

GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./apfs-fuse...(no debugging symbols found)...done. [New LWP 14174] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `./apfs-fuse -d 3 /dev/sda2 /tmp/federiMac'. Program terminated with signal SIGSEGV, Segmentation fault.

0 0x00005607feba9df0 in NormalizeFoldString(std::vector<char32_t, std::allocator >&, std::vector<char32_t, std::allocator > const&, bool)

()

(gdb) where

0 0x00005607feba9df0 in NormalizeFoldString(std::vector<char32_t, std::allocator >&, std::vector<char32_t, std::allocator > const&, bool)

()

1 0x00005607feba764f in StrCmpUtf8NormalizedFolded(unsigned char const, unsigned char const, bool) ()

2 0x00005607feb9150b in BTree::FindBin(std::shared_ptr const&, void const, unsigned long, int ()(void const, unsigned long, void const, unsigned long, void), void, BTree::FindMode) ()

3 0x00005607feb949f5 in BTree::GetIterator(BTreeIterator&, void const, unsigned long, int ()(void const, unsigned long, void const, unsigned long, void), void) ()

4 0x00005607feb8243c in ApfsDir::ListDirectory(std::vector<ApfsDir::DirRec, std::allocator >&, unsigned long) ()

5 0x00005607feb7c255 in apfs_readdir(fuse_req, unsigned long, unsigned long, long, fuse_file_info) ()

6 0x00007f93b7a020c6 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2

7 0x00007f93b7a036c1 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2

8 0x00007f93b79ffa6c in fuse_session_loop ()

from /lib/x86_64-linux-gnu/libfuse.so.2

9 0x00005607feb7af00 in main ()

(gdb) bt full

0 0x00005607feba9df0 in NormalizeFoldString(std::vector<char32_t, std::allocator >&, std::vector<char32_t, std::allocator > const&, bool)

()

No symbol table info available.

1 0x00005607feba764f in StrCmpUtf8NormalizedFolded(unsigned char const, unsigned char const, bool) ()

No symbol table info available.

2 0x00005607feb9150b in BTree::FindBin(std::shared_ptr const&, void const, unsigned long, int ()(void const, unsigned long, void const, unsigned long, void), void, BTree::FindMode) ()

No symbol table info available.

3 0x00005607feb949f5 in BTree::GetIterator(BTreeIterator&, void const, unsigned long, int ()(void const, unsigned long, void const, unsigned long, void), void) ()

No symbol table info available.

4 0x00005607feb8243c in ApfsDir::ListDirectory(std::vector<ApfsDir::DirRec, std::allocator >&, unsigned long) ()

No symbol table info available.

5 0x00005607feb7c255 in apfs_readdir(fuse_req, unsigned long, unsigned long, long, fuse_file_info) ()

No symbol table info available.

6 0x00007f93b7a020c6 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2

No symbol table info available. ---Type to continue, or q to quit---

7 0x00007f93b7a036c1 in ?? () from /lib/x86_64-linux-gnu/libfuse.so.2

No symbol table info available.

8 0x00007f93b79ffa6c in fuse_session_loop ()

from /lib/x86_64-linux-gnu/libfuse.so.2 No symbol table info available.

9 0x00005607feb7af00 in main ()

No symbol table info available. (gdb)

grep apfs-fuse /var/log/syslog

Jan 10 22:30:27 nemo kernel: [ 7820.204971] apfs-fuse[14174]: segfault at 0 ip 00005607feba9df0 sp 00007ffea4a39830 error 4 in apfs-fuse[5607feb6b000+5d000] Jan 10 22:30:27 nemo kernel: [ 7820.204977] Code: 49 8b 34 24 4d 8b 44 24 08 49 29 f0 49 c1 f8 02 49 83 e8 01 0f 84 9c 01 00 00 45 31 d2 eb 0b 0f 1f 00 4d 89 da 4d 39 d8 76 7c <42> 80 3c 17 00 4d 8d 5a 01 74 ed 4a 8d 1c 1f 80 3b 00 74 e4 0f 1f

Please let me know if you need more info

Thanks Fede

sgan81 commented 5 years ago

I see. Does this folder contain some special file names (non-ascii chars, etc ...)? Or very long file names?

Or is 'cucina internazionale' the file that caused it to crash? Would be very strange ... but I'll look into this.

sgan81 commented 5 years ago

It would also help if you enabled debugging symbols and rebuild the whole project before using gdb. The backtrace would be more useful then. Edit CMakeLists.txt and change set(CMAKE_BUILD_TYPE Release) to set(CMAKE_BUILD_TYPE Debug), then do a cmake, make clean, make.

federunix commented 5 years ago

Hi Simon, I'm afraid I can no longer reproduce the crash. The disk, which was coming from a broken iMac, with the files causing the crash, has been recycled on my new linux workstation, so I've already formatted the disk. I still have a backup of the disk on a TimeMachine drive, which I should use to recover some other data, I will try to restore the whole drive on a temporary disk, if I will be able to repro the crash I will rebuild the project with the debugging symbols enabled and update the issue. Sorry about that :(