My Android webview is crashing and the error dump from adb logcat tells me that libwebcore.so is the library causing the segmentation fault. How do you troubleshoot this?
My initial research took me to places like this thread: How to use addr2line in Android, which in essence says to get the non-stripped version of the library and use the addr2line utility to pinpoint the exact line causing the segmentation fault
The thread above says "Use the .so file under obj/local/armeabi, since this is the non-stripped version"...but I couldn't find libwebcore.so anywhere under /usr/local/android-ndk-r6 or /usr/local/android-sdk-mac_86 on my Mac, and I only found a stripped version of libwebcore.so under /system/lib on the Android device.
Is there a way I can get my hands on a non-stripped version of libwebcore.so? Or am I just not going about this the right way?
For reference, here is the error dump as spit out by adb logcat:
I/DEBUG ( 65): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 65): Build fingerprint: 'google/passion/passion:2.3.4/GRJ22/121341:user/release-keys'
I/DEBUG ( 65): pid: 611, tid: 618 >>> com.swishly.gap <<<
I/DEBUG ( 65): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
I/DEBUG ( 65): r0 00000002 r1 002f9564 r2 00000003 r3 008e79c8
I/DEBUG ( 65): r4 00000000 r5 002f9700 r6 00000000 r7 4470baf4
I/DEBUG ( 65): r8 4470bb64 r9 44520ea8 10 002ae048 fp 00000000
I/DEBUG ( 65): ip 00000000 sp 4470bad0 lr a851857b pc a851838e cpsr 00000030
I/DEBUG ( 65): d0 0061006300000000 d1 0064006500680000
I/DEBUG ( 65): d2 0077007400650000 d3 004c006b00720000
I/DEBUG ( 65): d4 007400610063006f d5 0053006e006f0069
I/DEBUG ( 65): d6 006300720075006f d7 0000000000000065
I/DEBUG ( 65): d8 0000000000000000 d9 0000000000000000
I/DEBUG ( 65): d10 0000000000000000 d11 0000000000000000
I/DEBUG ( 65): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 65): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 65): d16 41d39d979893f080 d17 41d39d9b0a07ff06
I/DEBUG ( 65): d18 41106a1000000000 d19 4024000000000000
I/DEBUG ( 65): d20 0000000000000000 d21 0000000000000000
I/DEBUG ( 65): d22 4024000000000000 d23 0000000000000000
I/DEBUG ( 65): d24 0000000000000000 d25 3ff0000000000000
I/DEBUG ( 65): d26 0000000000000000 d27 bff0000000000000
I/DEBUG ( 65): d28 0000000000000000 d29 3ff0000000000000
I/DEBUG ( 65): d30 0000000000000000 d31 3ff0000000000000
I/DEBUG ( 65): scr 20000013
I/DEBUG ( 65):
I/DEBUG ( 65): #00 pc 0021838e /system/lib/libwebcore.so
I/DEBUG ( 65): #01 pc 00218576 /system/lib/libwebcore.so
I/DEBUG ( 65): #02 pc 002186f8 /system/lib/libwebcore.so
I/DEBUG ( 65): #03 pc 0021873a /system/lib/libwebcore.so
I/DEBUG ( 65): #04 pc 0021875c /system/lib/libwebcore.so
I/DEBUG ( 65): #05 pc 0021879a /system/lib/libwebcore.so
I/DEBUG ( 65): #06 pc 0021febe /system/lib/libwebcore.so
I/DEBUG ( 65): #07 pc 00220df0 /system/lib/libwebcore.so
I/DEBUG ( 65): #08 pc 0022147c /system/lib/libwebcore.so
I/DEBUG ( 65): #09 pc 00017e34 /system/lib/libdvm.so
I/DEBUG ( 65):
I/DEBUG ( 65): code around pc:
I/DEBUG ( 65): a851836c 602303c2 eb03e002 602003c2 46206063
I/DEBUG ( 65): a851837c bf00bd70 b510680b b1134604 1c426818
I/DEBUG ( 65): a851838c 6820601a f7ff6023 4620fd55 bf00bd10
I/DEBUG ( 65): a851839c 4604b510 fd1ef7ff f6534620 4620fa73
I/DEBUG ( 65): a85183ac bf00bd10 4604b570 460e6cc0 f6acb168
I/DEBUG ( 65):
I/DEBUG ( 65): code around lr:
I/DEBUG ( 65): a8518558 d10242a5 2600462c 6823e017 f1b3b113
I/DEBUG ( 65): a8518568 d1f83fff e7f33408 1d216878 f7ff1980
I/DEBUG ( 65): a8518578 3408ff03 d00642a5 2b006823 f1b3d0f9
I/DEBUG ( 65): a8518588 d1013fff 462ce7f5 42ac3604 e8bdd1ec
I/DEBUG ( 65): a8518598 bf0081f0 b087b5f0 0710f100 4604ae03
I/DEBUG ( 65):
I/DEBUG ( 65): stack:
I/DEBUG ( 65): 4470ba90 00953a1c
I/DEBUG ( 65): 4470ba94 a83da669 /system/lib/libwebcore.so
I/DEBUG ( 65): 4470ba98 9de0413c
I/DEBUG ( 65): 4470ba9c 00000001
I/DEBUG ( 65): 4470baa0 00953a18
I/DEBUG ( 65): 4470baa4 0000a000
I/DEBUG ( 65): 4470baa8 4470bb64
I/DEBUG ( 65): 4470baac 44520ea8
I/DEBUG ( 65): 4470bab0 002ae048
I/DEBUG ( 65): 4470bab4 afd1362d /system/lib/libc.so
I/DEBUG ( 65): 4470bab8 4470baf4
I/DEBUG ( 65): 4470babc 00953a1c
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java or Kotlin crashes if it throws an unhandled exception, represented by the Throwable class.
throw new RuntimeException("This is a crash"); Make sure to remove the line after testing is done. Another way to crash an Android app is to make a DivideByZero exception. In the onCreate method of your activity, simply write an expression with a number being divided by 0.
You can checkout the whole WebKit xcode project along with the whole Android open source project with the link Kerubu provided (I did a few months ago, it takes multiple gigabytes & hours...) and probably create your own unstripped .so library (I didn't), but I doubt this is the easiest way to take on this issue.
Edit: it turns out android is mirrored on github, here's the WebCore project.
There is a good chance that your application is far easier to troubleshoot than the WebKit project!
I'll allow myself to throw a wild guess:
There are known bugs with javascript injection (also here) for some devices only that seem to be affecting some html app framework as well (such as PhoneGap, apparently), do you use the method addJavascriptInterface
? If so there is a workaround, calling the WebChromeClient
's onJsPrompt
and parsing the string to perform native calls from the webview.
Java to javascript:
webview.loadUrl("javascript:alert('toto');");
javascript to java:
in javascript:
prompt('this is the message', 'this is the default value');
and in java:
WebChromeClient chromeClient = new WebChromeClient(){
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, android.webkit.JsPromptResult result){
Log.d("javascriptPrompt", "prompt : "+url+"-"+message);
// should log "javascriptPrompt, "prompt: null - this is the message"
// parse the message and do whatever you want here
result.confirm();
return true;
}
}
webview.setChromeClient(chromeClient);
Not 100% sure but is the source for libwebkit.so to be found in Android Open Source Project?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With