corrupted filesystem, mount.exfat crash and exfatfsck segfault

291 views
Skip to first unread message

paran.a...@gmail.com

unread,
Dec 23, 2014, 6:43:25 PM12/23/14
to ex...@googlegroups.com
Hello,

I have a corrupted exfat image copied from an Android phone SD-card. Symptoms on the phone was that the Camera app could not take pictures.

When mounting the filesystem using fuse-exfat (1.1.0) there are 14 files in the DCIM/Camera directory that results in Input/Output error when trying to read them using commands like "cp". Tryng to copy the files using rsync instead causes the mount.exfat process to crash. See below for debug log of first mounting the filesystem, then reading the same file first using cp and then using rsync.

Running exfatfsck (exfat-utils 1.1.1) on this filesystem ends with a segfault. (I am aware that exfatfsck can't repair filesystems, guess I will have to find a computer running Windows for that)

exfatfsck run with backtrace:

$ gdb -q --args ./exfatfsck /nobackup/xperia-ray-sdcard.img
Reading symbols from ./exfatfsck...done.
(gdb) run
Starting program: /nobackup/exfat/x/exfat-utils-1.1.1/fsck/exfatfsck /nobackup/xperia-ray-sdcard.img
exfatfsck 1.1.1
Checking file system on /nobackup/xperia-ray-sdcard.img.
File system version           1.0
Sector size                 512 bytes
Cluster size                 32 KB
Volume size                3758 MB
Used space                 3138 MB
Available space             620 MB

Program received signal SIGSEGV, Segmentation fault.
0x0000000000401458 in nodeck (ef=ef@entry=0x7fffffffdc30, node=node@entry=0x62f670)
    at fsck/main.c:52
52                      if (BMAP_GET(ef->cmap.chunk, c - EXFAT_FIRST_DATA_CLUSTER) == 0)
(gdb) bt
#0  0x0000000000401458 in nodeck (ef=ef@entry=0x7fffffffdc30, node=node@entry=0x62f670)
    at fsck/main.c:52
#1  0x00000000004015ec in dirck (ef=ef@entry=0x7fffffffdc30,
    path=path@entry=0x617660 "/DCIM/Camera") at fsck/main.c:117
#2  0x00000000004015a3 in dirck (ef=ef@entry=0x7fffffffdc30,
    path=path@entry=0x613be0 "/DCIM") at fsck/main.c:112
#3  0x00000000004015a3 in dirck (ef=ef@entry=0x7fffffffdc30, path=path@entry=0x40734f "")
    at fsck/main.c:112
#4  0x000000000040124a in fsck (ef=0x7fffffffdc30) at fsck/main.c:129
#5  main (argc=<optimized out>, argv=<optimized out>) at fsck/main.c:167
(gdb)


mount.exfat debug log:

$ sudo mount.exfat -d -o ro /dev/loop1 mnt
FUSE exfat 1.1.0
FUSE library version: 2.9.2
nullpath_ok: 0
nopath: 0
utime_omit_ok: 0
unique: 1, opcode: INIT (26), nodeid: 0, insize: 56, pid: 0
INIT: 7.22
flags=0x0000f7fb
max_readahead=0x00020000
   INIT: 7.19
   flags=0x00000031
   max_readahead=0x00020000
   max_write=0x00020000
   max_background=0
   congestion_threshold=0
   unique: 1, success, outsize: 40
unique: 2, opcode: STATFS (17), nodeid: 1, insize: 40, pid: 17579
statfs /
   unique: 2, success, outsize: 96
unique: 3, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 2582
getattr /
   unique: 3, success, outsize: 120
unique: 4, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 2509
getattr /
   unique: 4, success, outsize: 120
unique: 5, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 17579
getattr /
   unique: 5, success, outsize: 120
unique: 6, opcode: STATFS (17), nodeid: 1, insize: 40, pid: 17579
statfs /
   unique: 6, success, outsize: 96


### Will now run: cp mnt/DCIM/Camera/IMG_20140211_105238.jpg sync2/


unique: 7, opcode: LOOKUP (1), nodeid: 1, insize: 45, pid: 21741
LOOKUP /DCIM
getattr /DCIM
   NODEID: 2
   unique: 7, success, outsize: 144
unique: 8, opcode: LOOKUP (1), nodeid: 2, insize: 47, pid: 21741
LOOKUP /DCIM/Camera
getattr /DCIM/Camera
   NODEID: 3
   unique: 8, success, outsize: 144
unique: 9, opcode: LOOKUP (1), nodeid: 3, insize: 64, pid: 21741
LOOKUP /DCIM/Camera/IMG_20140211_105238.jpg
getattr /DCIM/Camera/IMG_20140211_105238.jpg
   NODEID: 4
   unique: 9, success, outsize: 144
unique: 10, opcode: OPEN (14), nodeid: 4, insize: 48, pid: 21741
open flags: 0x8000 /DCIM/Camera/IMG_20140211_105238.jpg
   open[139702632742752] flags: 0x8000 /DCIM/Camera/IMG_20140211_105238.jpg
   unique: 10, success, outsize: 32
unique: 11, opcode: READ (15), nodeid: 4, insize: 80, pid: 21741
read[139702632742752] 131072 bytes from 0 flags: 0x8000
ERROR: invalid cluster 0x0 while reading.
   unique: 11, error: -5 (Input/output error), outsize: 16
unique: 12, opcode: READ (15), nodeid: 4, insize: 80, pid: 21741
read[139702632742752] 4096 bytes from 0 flags: 0x8000
   read[139702632742752] 4096 bytes from 0
   unique: 12, success, outsize: 4112
unique: 13, opcode: READ (15), nodeid: 4, insize: 80, pid: 21741
read[139702632742752] 4096 bytes from 4096 flags: 0x8000
   read[139702632742752] 4096 bytes from 4096
   unique: 13, success, outsize: 4112
unique: 14, opcode: READ (15), nodeid: 4, insize: 80, pid: 21741
read[139702632742752] 4096 bytes from 8192 flags: 0x8000
   read[139702632742752] 4096 bytes from 8192
   unique: 14, success, outsize: 4112
unique: 15, opcode: READ (15), nodeid: 4, insize: 80, pid: 21741
read[139702632742752] 4096 bytes from 12288 flags: 0x8000
   read[139702632742752] 4096 bytes from 12288
   unique: 15, success, outsize: 4112
unique: 16, opcode: READ (15), nodeid: 4, insize: 80, pid: 21741
read[139702632742752] 4096 bytes from 16384 flags: 0x8000
   read[139702632742752] 4096 bytes from 16384
   unique: 16, success, outsize: 4112
unique: 17, opcode: READ (15), nodeid: 4, insize: 80, pid: 21741
read[139702632742752] 4096 bytes from 20480 flags: 0x8000
   read[139702632742752] 4096 bytes from 20480
   unique: 17, success, outsize: 4112
unique: 18, opcode: READ (15), nodeid: 4, insize: 80, pid: 21741
read[139702632742752] 4096 bytes from 24576 flags: 0x8000
   read[139702632742752] 4096 bytes from 24576
   unique: 18, success, outsize: 4112
unique: 19, opcode: READ (15), nodeid: 4, insize: 80, pid: 21741
read[139702632742752] 4096 bytes from 28672 flags: 0x8000
   read[139702632742752] 4096 bytes from 28672
   unique: 19, success, outsize: 4112
unique: 20, opcode: READ (15), nodeid: 4, insize: 80, pid: 21741
read[139702632742752] 4096 bytes from 32768 flags: 0x8000
ERROR: invalid cluster 0x0 while reading.
   unique: 20, error: -5 (Input/output error), outsize: 16
unique: 21, opcode: READ (15), nodeid: 4, insize: 80, pid: 21741
read[139702632742752] 4096 bytes from 32768 flags: 0x8000
ERROR: invalid cluster 0x0 while reading.
   unique: 21, error: -5 (Input/output error), outsize: 16
unique: 22, opcode: FLUSH (25), nodeid: 4, insize: 64, pid: 21741
flush[139702632742752]
   unique: 22, success, outsize: 16
unique: 23, opcode: RELEASE (18), nodeid: 4, insize: 64, pid: 0
release[139702632742752] flags: 0x8000
   unique: 23, success, outsize: 16


# Will now run: rsync mnt/DCIM/Camera/IMG_20140211_105238.jpg sync2/


unique: 24, opcode: LOOKUP (1), nodeid: 1, insize: 45, pid: 21747
LOOKUP /DCIM
getattr /DCIM
   NODEID: 2
   unique: 24, success, outsize: 144
unique: 25, opcode: LOOKUP (1), nodeid: 2, insize: 47, pid: 21747
LOOKUP /DCIM/Camera
getattr /DCIM/Camera
   NODEID: 3
   unique: 25, success, outsize: 144
unique: 26, opcode: ACCESS (34), nodeid: 3, insize: 48, pid: 21747
   unique: 26, error: -38 (Function not implemented), outsize: 16
unique: 27, opcode: LOOKUP (1), nodeid: 3, insize: 64, pid: 21747
LOOKUP /DCIM/Camera/IMG_20140211_105238.jpg
getattr /DCIM/Camera/IMG_20140211_105238.jpg
   NODEID: 4
   unique: 27, success, outsize: 144
unique: 28, opcode: OPEN (14), nodeid: 4, insize: 48, pid: 21747
open flags: 0x8000 /DCIM/Camera/IMG_20140211_105238.jpg
   open[139702632742752] flags: 0x8000 /DCIM/Camera/IMG_20140211_105238.jpg
   unique: 28, success, outsize: 32
unique: 29, opcode: READ (15), nodeid: 4, insize: 80, pid: 21747
read[139702632742752] 4096 bytes from 32768 flags: 0x8000
ERROR: invalid cluster 0x0 while reading.
   unique: 29, error: -5 (Input/output error), outsize: 16
unique: 30, opcode: READ (15), nodeid: 4, insize: 80, pid: 21747
read[139702632742752] 4096 bytes from 32768 flags: 0x8000
ERROR: invalid cluster 0x0 while reading.
   unique: 30, error: -5 (Input/output error), outsize: 16
unique: 31, opcode: READ (15), nodeid: 4, insize: 80, pid: 21747
read[139702632742752] 131072 bytes from 262144 flags: 0x8000
BUG: bad cluster 0x0.
$


Thanks for all your work on exfat support.

Pär Lindfors

Andrew Nayenko

unread,
Dec 24, 2014, 4:03:36 PM12/24/14
to ex...@googlegroups.com
Hi Pär,

Thanks for the detailed report. Was the FS corrupt by fuse-exfat or
Sony's driver?
--
Andrew Nayenko <res...@gmail.com>

paran.a...@gmail.com

unread,
Dec 24, 2014, 5:02:21 PM12/24/14
to ex...@googlegroups.com
Hi Andrew,


On Wednesday, 24 December 2014 22:03:36 UTC+1, Andrew Nayenko wrote:
Thanks for the detailed report. Was the FS corrupt by fuse-exfat or
Sony's driver?

Sorry if I was being unclear. All the corruption have happened on the phone. It has a bad battery, so it have most likely had a few unclean shutdowns. I just put the SD-card into a computer for the first time yesterday.

My intent was to report that this filesystem can cause both fuse-exfat and exfatfsck to crash.

Regards,
Pär

Andrew Nayenko

unread,
Dec 26, 2014, 6:22:30 AM12/26/14
to exfat, Pär Lindfors
Hi Pär,

> Sorry if I was being unclear. All the corruption have happened on the phone.
> It has a bad battery, so it have most likely had a few unclean shutdowns. I
> just put the SD-card into a computer for the first time yesterday.
>
> My intent was to report that this filesystem can cause both fuse-exfat and
> exfatfsck to crash.

Got it. I'll add some more consistency checks. Thanks again for reporting.

--
Andrew Nayenko <res...@gmail.com>
Reply all
Reply to author
Forward
0 new messages