Wednesday, March 9, 2016

Solved the mount.exfat SIGSEGV crash!

There's a problem with mount.exfat in many ROMs, including Cyanogen 12.1 and, I suppose, Cyanogen 13. It sometimes crashes under load, notably from SQLite (AnkiDroid in my case). From the user side, the SD card just dismounts. Logcat says:

Code:

I/DEBUG  ( 2621): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x2c
W/NativeCrashListener( 4743): Couldn't find ProcessRecord for pid 10218
I/DEBUG  ( 2621):    r0 b6fc0838  r1 00000000  r2 ffffffc8  r3 b6f7cde4
E/DEBUG  ( 2621): AM write failure (32 / Broken pipe)
I/DEBUG  ( 2621):    r4 b6fc0838  r5 befdf730  r6 00000000  r7 b6fbee0c
I/DEBUG  ( 2621):    r8 b703bfb0  r9 b6fc0838  sl 00000001  fp 00000000
I/DEBUG  ( 2621):    ip b6fbef2c  sp befdf668  lr b6fa2ed3  pc b6fa655a  cpsr 80000030
I/DEBUG  ( 2621):
I/DEBUG  ( 2621): backtrace:
I/DEBUG  ( 2621):    #00 pc 0000655a  /system/bin/mount.exfat
I/DEBUG  ( 2621):    #01 pc 00002ecf  /system/bin/mount.exfat
I/DEBUG  ( 2621):    #02 pc 0000a4cb  /system/bin/mount.exfat
I/DEBUG  ( 2621):    #03 pc 0000a52b  /system/bin/mount.exfat
I/DEBUG  ( 2621):    #04 pc 0000d361  /system/bin/mount.exfat
I/DEBUG  ( 2621):    #05 pc 0000e02b  /system/bin/mount.exfat
I/DEBUG  ( 2621):    #06 pc 0000ef03  /system/bin/mount.exfat
I/DEBUG  ( 2621):    #07 pc 0000c843  /system/bin/mount.exfat
I/DEBUG  ( 2621):    #08 pc 00009133  /system/bin/mount.exfat
I/DEBUG  ( 2621):    #09 pc 0000317d  /system/bin/mount.exfat
I/DEBUG  ( 2621):    #10 pc 0000f4a9  /system/lib/libc.so (__libc_init+44)
I/DEBUG  ( 2621):    #11 pc 00002964  /system/bin/mount.exfat
I/DEBUG  ( 2621):
I/DEBUG  ( 2621): Tombstone written to: /data/tombstones/tombstone_00

Here's one person with this, here's another, and even a Cyanogen bug report (somehow closed).

Anyway, this is how the stack looks with symbols:

Code:

I/DEBUG  ( 2622):    #00 pc 0000655a  /system/bin/mount.exfat (exfat_flush_node+21)
I/DEBUG  ( 2622):    #01 pc 00002ecf  /system/bin/mount.exfat (fuse_exfat_fsync+14)
I/DEBUG  ( 2622):    #02 pc 0000a4cb  /system/bin/mount.exfat (fuse_fs_fsyncdir+66)
I/DEBUG  ( 2622):    #03 pc 0000a52b  /system/bin/mount.exfat (fuse_lib_fsyncdir+70)
I/DEBUG  ( 2622):    #04 pc 0000d361  /system/bin/mount.exfat (do_fsyncdir+52)
I/DEBUG  ( 2622):    #05 pc 0000e02b  /system/bin/mount.exfat (fuse_ll_process_buf+1042)
I/DEBUG  ( 2622):    #06 pc 0000ef03  /system/bin/mount.exfat (fuse_session_process_buf+12)
I/DEBUG  ( 2622):    #07 pc 0000c843  /system/bin/mount.exfat (fuse_session_loop+122)
I/DEBUG  ( 2622):    #08 pc 00009133  /system/bin/mount.exfat (fuse_loop+278)
I/DEBUG  ( 2622):    #09 pc 0000317d  /system/bin/mount.exfat (mount_exfat_main+652)
I/DEBUG  ( 2622):    #10 pc 0000f4a9  /system/lib/libc.so (__libc_init+44)
I/DEBUG  ( 2622):    #11 pc 00002964  /system/bin/mount.exfat (_start+96)

Turns out this has been fixed (at least bandaided) but the fix never made it into the Cyanogen.

I compiled mount.exfat with the fix and tried it on my device, here's the fixed version (both default version and the one with symbols):
mount.exfat.tar.gz

How to install:
  1. You need to be running Cyanogen 12.1 (I'm not sure if this binary will work for other versions, look below how to rebuild). Adb has to be enabled and granted root (this is done in developer settings, "Enable ADB", "Enable root for ADB") and otherwise adb has to be working.
  2. Code:

    adb shell
    su

  3. 3. Remount your /system as read-write:
    Code:

    mount -o remount,rw -t ext4 /res/dev/system /system
  4. Back to the host terminal,
    Code:

    adb pull /system/bin/mount.exfat mount.exfat.old
    adb push mount.exfat /system/bin/

    Push the version with symbols if you want to investigate a crash.
  5. Reboot the device.

I've been on this version for a day and it really doesn't crash.

If you use a different ROM or device (googled this topic) or want to build this yourself:
  1. Checkout and build Cyanogen for your device somehow (you won't need most of it). There's lots of guides out there.
  2. Apply the patch above to the /android/system/external/exfat/libexfat/node.c (simply type in the added lines).
  3. You can build only libexfat by going there and executing mm (or even mmp to push mount.exfat to the phone automatically!) but it won't work until you build the whole distribution to that point at least once. (You don't have to build to the end)

Hope this helps someone and hope this is the correct forum because it doesn't let me post in android development.


from xda-developers http://ift.tt/1TMu1Bm
via IFTTT

No comments:

Post a Comment