Solved the mount.exfat SIGSEGV crash!

Search This thread

himselfv

New member
Mar 4, 2016
4
3
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're using 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.
 
Last edited:

francwalter

Senior Member
Nov 13, 2011
610
108
Thanks. I just installed it, and it didnt crash on exFAT.
But then, when I double checked if the old mount.exfat file does still crash on exFAT, I couldnt reproduce the old bug.
It didnt crash anymore on my CM12.1 from 26.12.2016 (last nighty).
Maybe it was already fixed? Or I didn't test exact enough.
I have a SGS4.
 

himselfv

New member
Mar 4, 2016
4
3
It doesn't seem they accepted that patch. Here's the current code:

https://github.com/CyanogenMod/android_external_exfat/blob/cm-12.0/libexfat/node.c

Last change was in 2014:
https://github.com/CyanogenMod/android_external_exfat/blob/cm-12.0/libexfat/node.c

In exfat_flush_node, note how they do

if (!(node->flags & EXFAT_ATTRIB_DIRTY))

Without first checking that node is non-NULL.

So that part is not fixed. (Neither simply building the latest mount.exfat from the repo worked for me)

On the other hand, since the crash is not that common, it is probable that NULL only gets passed there under some special circumstances in the
first place. Perhaps whatever it was that triggered it in your case, it went away.
 
  • Like
Reactions: francwalter

francwalter

Senior Member
Nov 13, 2011
610
108
In any case I have changed the files, so the bug will never happen again :)
I "only" need now to change the sd-card back to exFAT again, which is a bit long, because since some months I have a 128 GByte sd-card.
But I will do it, because the 4 GB limit can make problems in future.
 

francwalter

Senior Member
Nov 13, 2011
610
108
Switched today from FAT32 to exFAT, on my Mac with the 10 days free trial of Paragon, because in my sd-card there is a ext4 partition for the Link2SD which I heavily use.
That why it a bit more difficult to switch.
But works.
 

francwalter

Senior Member
Nov 13, 2011
610
108
I had to reflash my phone (not a complete reset, just flash, because Wi-Fi didn't work anymore). This time I tried the snapshot, not the last nightly from 26.12.2016. I forgot to flash the fix and voila! I had again that bug! So I installed the mount.exfat fix and after reboot it works again! So I guess in some way, the bug has gone in the 26.12. last nightly version, even if the file is the same. Maybe in some other way the error is catched?
Don't know but am happy that this fix exists :)
Thank again!
 

Garfield1970

Senior Member
May 4, 2005
91
20
Bascharage
THANKS ! , this fixed my problems :)

I was able to reproduce the error easily , every time I exited TomTom Go since I inserted my new 64 GB card , my /storage/sdcard1 would be unmounted :(

( Samsung Galaxy S4 Mini Duos / CM12.1 )

Installed your fix and it's working like a charm now .... I still have my external SD after exiting TomTom :)
 

francwalter

Senior Member
Nov 13, 2011
610
108
Great! I had CM12.1 last snapshot on my old SGS2 and indeed that bluddy bug is present here as well.
Once again your fix helped a lot! Thank!
The last nightly of 12.1 is taken away from the download sites unfortunately so I had to install that buggy last snapshot, which has this bug but not the last nighly had it I remember from SGS4's CM12.1
 

axelpix

Senior Member
Sep 12, 2008
147
22
Samsung Galaxy S7
Is this bug still there with CM13?

Hi Frank and all,

I kept away from CM for a while now, just because I never was able to get my LocusPro map directories on external SD to work propperly. Was CM12.1 by that time. Also the fix here in this thread seems to be made for CM12.1

Any hint on how to proceed with CM13? Is it all good out of the box now? Or can I apply this fix here to CM13 as well?

BR
Axel
 

francwalter

Senior Member
Nov 13, 2011
610
108
I don't think this is good idea, but not know if I am wrong. I didn't need that patch on CM13 anymore.

BUT: on CM13 the external sdcard write restrictions from Google weren't fixed by CM anymore, so I needed other tools to fix it: [Xposed][MODULE][4.0+] XInternalSD
Only with this Xposed module I got running Locus again. The way to there was a pain in my glass.
But if you have root (which you must have for this fix anyway), it is easy to install. First Xposed, then this module (through Xposed).
 
  • Like
Reactions: axelpix

yzdadev

New member
Feb 26, 2012
2
1
This solved my problem with OsmAnd~ maps on /storage/sdcard1/.. (exfat external sdcard) on Note4 / CM12.1 / 20160106-nightly-trltexx
Just used your mount.exfat, no new build needed.

THANKS!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    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're using 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.
    1
    It doesn't seem they accepted that patch. Here's the current code:

    https://github.com/CyanogenMod/android_external_exfat/blob/cm-12.0/libexfat/node.c

    Last change was in 2014:
    https://github.com/CyanogenMod/android_external_exfat/blob/cm-12.0/libexfat/node.c

    In exfat_flush_node, note how they do

    if (!(node->flags & EXFAT_ATTRIB_DIRTY))

    Without first checking that node is non-NULL.

    So that part is not fixed. (Neither simply building the latest mount.exfat from the repo worked for me)

    On the other hand, since the crash is not that common, it is probable that NULL only gets passed there under some special circumstances in the
    first place. Perhaps whatever it was that triggered it in your case, it went away.
    1
    I don't think this is good idea, but not know if I am wrong. I didn't need that patch on CM13 anymore.

    BUT: on CM13 the external sdcard write restrictions from Google weren't fixed by CM anymore, so I needed other tools to fix it: [Xposed][MODULE][4.0+] XInternalSD
    Only with this Xposed module I got running Locus again. The way to there was a pain in my glass.
    But if you have root (which you must have for this fix anyway), it is easy to install. First Xposed, then this module (through Xposed).