couchbase / couchbase-lite-android-ce

The community edition of couchbase lite for android
Apache License 2.0
9 stars 1 forks source link

Crash when trying to profile an application #10

Closed RocketRider closed 5 years ago

RocketRider commented 5 years ago

I am using an Android 8.1 device (arm-v7), Couchbase Lite 2.5, AGP and AS 3.4.1. When I try to profile the app, the app crashes within the cb-lite JNI lib. The crash occurs when I write something to the DB.


    --------- beginning of crash
2019-05-21 14:13:53.508 com.xxx.yyy A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x1f in tid 9209 (pool-8-thread-1), pid 9160 (xxx.yyy)
2019-05-21 14:13:53.564 ? W/crash_dump32: type=1400 audit(0.0:76): avc: denied { search } for name="com.xxx.yyy" dev="dm-2" ino=527669 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
2019-05-21 14:13:53.592 ? I/crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
2019-05-21 14:13:53.593 ? I//system/bin/tombstoned: received crash request for pid 9160
2019-05-21 14:13:53.594 ? I/crash_dump32: performing dump of process 9160 (target tid = 9209)
2019-05-21 14:13:53.595 ? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2019-05-21 14:13:53.595 ? A/DEBUG: Build fingerprint: 'Cat/CatS61/CatS61:8.1.0/OPM1.171019.011/LTE_D0201121.0_S61_0.039.00:user/release-keys'
2019-05-21 14:13:53.595 ? A/DEBUG: Revision: '0'
2019-05-21 14:13:53.595 ? A/DEBUG: ABI: 'arm'
2019-05-21 14:13:53.595 ? A/DEBUG: pid: 9160, tid: 9209, name: pool-8-thread-1  >>> com.xxx.yyy <<<
2019-05-21 14:13:53.595 ? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1f
2019-05-21 14:13:53.595 ? A/DEBUG: Cause: null pointer dereference
2019-05-21 14:13:53.595 ? A/DEBUG:     r0 c7cba500  r1 ffffffff  r2 00000000  r3 cb184df4
2019-05-21 14:13:53.595 ? A/DEBUG:     r4 c7cba4a8  r5 c7cba500  r6 00000000  r7 c7cba450
2019-05-21 14:13:53.595 ? A/DEBUG:     r8 00000000  r9 cb19a9cf  sl 00000001  fp 00000000
2019-05-21 14:13:53.595 ? A/DEBUG:     ip cb3a417c  sp c7cba450  lr cb31ad17  pc cb31b230  cpsr 80070030
2019-05-21 14:13:53.594 ? W/crash_dump32: type=1400 audit(0.0:77): avc: denied { search } for name="com.xxx.yyy" dev="dm-2" ino=527669 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
2019-05-21 14:13:53.597 ? A/DEBUG: backtrace:
2019-05-21 14:13:53.597 ? A/DEBUG:     #00 pc 00270230  /data/app/com.xxx.yyy-R_DyW_-TQaE8szARnAFdSw==/lib/arm/libLiteCoreJNI.so
2019-05-21 14:13:53.597 ? A/DEBUG:     #01 pc 0026fd13  /data/app/com.xxx.yyy-R_DyW_-TQaE8szARnAFdSw==/lib/arm/libLiteCoreJNI.so
2019-05-21 14:13:53.597 ? A/DEBUG:     #02 pc 002660bb  /data/app/com.xxx.yyy-R_DyW_-TQaE8szARnAFdSw==/lib/arm/libLiteCoreJNI.so (__gxx_personality_v0+330)
2019-05-21 14:13:53.597 ? A/DEBUG:     #03 pc 0018bee4  /data/data/com.xxx.yyy/libperfa_arm.so
2019-05-21 14:13:53.597 ? A/DEBUG:     #04 pc 0018c808  /data/data/com.xxx.yyy/libperfa_arm.so

As it does only occur if the AS profiler is running, I did also report it to google: https://issuetracker.google.com/issues/133166400

RocketRider commented 5 years ago

I can reproduce it with the sample from couchbase. I had to change two things:

  1. Change the ARM version to v7, with ARMv8 it did not crash.
  2. add a write operation to the sample. My Fork: https://github.com/RocketRider/mobile-travel-sample

Now I can reproduce the issue with the following steps:

  1. Start the App
  2. Add Profiler
  3. Click on "Proceed as guest"

Tested with following devices: CAT S61 - Android 8.1: Crash Samsung S9 - Android 9.0: Crash Pixel 2 - Android 9.0: Crash Samsung Tab - Android 5.0: No Crash

Sandychuang8 commented 5 years ago

Thanks Michael for all these detail steps to reproduce. I will look into it and get back to you as soon as I have an answer. -Sandy

bmeike commented 5 years ago

Michael, can we get about double that much logcat, on either side of the failure (5x, total)? We don't have any of the specific devices on which you are seeing the crash.

RocketRider commented 5 years ago

Thank you for looking into it. I guess it will crash on any Android 8+ device with an arm cpu.

Here is the full log from starting the app until the crash: profiler-crash.txt

bmeike commented 5 years ago

@RocketRider I am moving this issue to the couchbase-lite-android-ce repo. Please follow it there

bmeike commented 5 years ago

This seems to be a known problem with the Studio Profiler. It is scribbling on the compiled code, so it is not entirely surprising that it has trouble with native libraries. There appears to be some evidence that the problem is specific to certain versions of AS and specific devices (e.g.: this )

Tring-green commented 4 years ago

It perhaps an android studio profile bug. Delete the whole codecache directory in your application package root path(data/data/pacakge_name/codecache).

mzhua commented 2 years ago

It perhaps an android studio profile bug. Delete the whole codecache directory in your application package root path(data/data/pacakge_name/codecache).

thank u, it works for me