[Galaxy S 4 i9505 Original Android Development] wpyh:
Hi AntaresOne / other developers here,

I was poking around the logs to learn more about the Bluetooth crashes, with the error message "Bluetooth Share has stopped", and found this on my device:

10-06 10:34:15.647 F/libc ( 5302): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 5888 (bluedroid wake/)
10-06 10:34:15.677 I/DEBUG ( 225): property debug.db.uid not set; NOT waiting for gdb.
10-06 10:34:15.677 I/DEBUG ( 225): HINT: adb shell setprop debug.db.uid 100000
10-06 10:34:15.677 I/DEBUG ( 225): HINT: adb forward tcp:5039 tcp:5039
10-06 10:34:15.787 I/DEBUG ( 225): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-06 10:34:15.787 I/DEBUG ( 225): Build fingerprint: 'samsung/jfltexx/jflte:5.0.1/LRX22C/I9505XXUHOB7:user/release-keys'
10-06 10:34:15.787 I/DEBUG ( 225): Revision: '11'
10-06 10:34:15.787 I/DEBUG ( 225): ABI: 'arm'
10-06 10:34:15.787 I/DEBUG ( 225): pid: 5302, tid: 5888, name: bluedroid wake/ >>> com.android.bluetooth <<<
10-06 10:34:15.787 I/DEBUG ( 225): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
10-06 10:34:15.847 I/DEBUG ( 225): r0 b32ebde8 r1 00000000 r2 00000003 r3 aefd93d4
10-06 10:34:15.847 I/DEBUG ( 225): r4 00000001 r5 aefd938c r6 00000000 r7 00000002
10-06 10:34:15.847 I/DEBUG ( 225): r8 0000001f r9 00000c00 sl aefb33a8 fp 00000803
10-06 10:34:15.847 I/DEBUG ( 225): ip aefcade8 sp a15d3cf8 lr aef6dc13 pc 00000000 cpsr 60070010
10-06 10:34:15.847 I/DEBUG ( 225):
10-06 10:34:15.847 I/DEBUG ( 225): backtrace:
10-06 10:34:15.847 I/DEBUG ( 225): #00 pc 00000000 <unknown>
10-06 10:34:15.847 I/DEBUG ( 225): #01 pc 00158c11 /system/lib/hw/bluetooth.default.so (vendor_ssrcleanup+16)
10-06 10:34:15.847 I/DEBUG ( 225): #02 pc 0003c1a3 /system/lib/hw/bluetooth.default.so (bte_ssr_cleanup+58)
10-06 10:34:15.847 I/DEBUG ( 225): #03 pc 00127ca5 /system/lib/hw/bluetooth.default.so (btu_hcif_cmd_timeout+548)
10-06 10:34:15.857 I/DEBUG ( 225): #04 pc 00128823 /system/lib/hw/bluetooth.default.so (btu_task+1130)
10-06 10:34:15.857 I/DEBUG ( 225): #05 pc 000d883d /system/lib/hw/bluetooth.default.so
10-06 10:34:15.857 I/DEBUG ( 225): #06 pc 00014f77 /system/lib/libc.so (__pthread_start(void*)+38)
10-06 10:34:15.857 I/DEBUG ( 225): #07 pc 000121eb /system/lib/libc.so (__start_thread+10)
10-06 10:34:17.488 I/DEBUG ( 225):
10-06 10:34:17.488 I/DEBUG ( 225): Tombstone written to: /data/tombstones/tombstone_09

Then I searched for the function vendor_ssrcleanup(), and I found it here: https://github.com/CyanogenMod/andr...2169ac7a1f6a30ff16fa9fa38507/hci/src/vendor.c

void vendor_ssrcleanup(void) {
if (vendor_interface)
vendor_interface->ssr_cleanup();
}

It's interesting what the comments say about the function here: https://github.com/CyanogenMod/andr...ac7a1f6a30ff16fa9fa38507/hci/include/vendor.h

// SSR cleanup to close transport FDs and power off the chip
// This function is invoked to recover from error enabling/disabling BT
// and to during hardware failure
void vendor_ssrcleanup(void);

The logs specifically states that vendor_ssrcleanup() calls a function at NULL. I think this could be the case, if somehow vendor_interface->ssr_cleanup() gets reset to NULL or maybe it wasn't initialized at all.

10-06 10:34:15.847 I/DEBUG ( 225): backtrace:
10-06 10:34:15.847 I/DEBUG ( 225): #00 pc 00000000 <unknown>
10-06 10:34:15.847 I/DEBUG ( 225): #01 pc 00158c11 /system/lib/hw/bluetooth.default.so (vendor_ssrcleanup+16)

Maybe we can have a workaround here? Like this:

void vendor_ssrcleanup(void) {
if (vendor_interface)
if (vendor_interface->ssr_cleanup)
vendor_interface->ssr_cleanup();
}

Yes, I understand that this doesn't actually fix the bug... it just prevents the crash, the real cause may be somewhere else... but won't it at least make bluetooth usable? :D :fingers-crossed:

I'm don't know how to compile the code, so... maybe you can build a library file (bluetooth.default.so) and let us test it?

Thanks. :highfive: