We are moving to Discord!

Join us on the Countly Community Discord Server! Engage in discussions, share your feature ideas, and learn from fellow Countly users to build exceptional apps and experiences.

A deadlock in countly?

Hello,

We are using Countly in our project, and recently we encountered an ANR in our app, after anylized the anr file, i think there is a deadlock bug in countly, could anyone please help on this?
I put the call stack treads below which have potential issues, 

    call stack of thread-1
    #00 pc 0000000000086b4c  /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28) (BuildId: a790cdbd8e44ea8a90802da343cb82ce)
    #01 pc 00000000001ad950  /apex/com.android.art/lib64/libart.so (art::Mutex::ExclusiveLock(art::Thread*)+440) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #02 pc 0000000000496e50  /apex/com.android.art/lib64/libart.so (void art::Monitor::Lock<(art::LockReason)1>(art::Thread*)+524) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #03 pc 000000000049d030  /apex/com.android.art/lib64/libart.so (art::Monitor::MonitorEnter(art::Thread*, art::ObjPtr<art::mirror::Object>, bool)+456) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #04 pc 000000000066c344  /apex/com.android.art/lib64/libart.so (artLockObjectFromCode+32) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #05 pc 000000000012af90  /apex/com.android.art/lib64/libart.so (mterp_op_monitor_enter+16) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #06 pc 00000000003d6df4  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.Countly.isLoggingEnabled)
    #07 pc 000000000067e7f4  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+1520) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #08 pc 000000000012d814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #09 pc 00000000003e1a4c  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.ModuleLog.logEnabled+16)
    #10 pc 000000000067e7f4  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+1520) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #11 pc 000000000012d814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #12 pc 00000000003e1cc8  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.ModuleLog.w)
    #13 pc 000000000067e7f4  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+1520) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #14 pc 000000000012d814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #15 pc 00000000003e1cae  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.ModuleLog.w+2)
    #16 pc 000000000067e7f4  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+1520) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #17 pc 000000000012d814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #18 pc 00000000003d650a  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.CountlyStore.addConnection+118)
    #19 pc 000000000067e7f4  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+1520) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #20 pc 000000000012d814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #21 pc 00000000003d46b8  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.ConnectionQueue.sendCrashReport+188)
    #22 pc 000000000067e7f4  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+1520) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #23 pc 000000000012d814  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #24 pc 00000000003d539e  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.Countly$4.uncaughtException+138)

in the call stack of thread-1, counly has below lock sequence:

ly.count.android.sdk.CountlyStore.addConnection -> lock CountlyStore
ly.count.android.sdk.Countly.isLoggingEnabled -> lock Countly

 

    call stack of thread-2
    #00 pc 0000000000086b4c  /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28) (BuildId: a790cdbd8e44ea8a90802da343cb82ce)
    #01 pc 00000000001ad950  /apex/com.android.art/lib64/libart.so (art::Mutex::ExclusiveLock(art::Thread*)+440) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #02 pc 0000000000496e50  /apex/com.android.art/lib64/libart.so (void art::Monitor::Lock<(art::LockReason)1>(art::Thread*)+524) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #03 pc 000000000049d030  /apex/com.android.art/lib64/libart.so (art::Monitor::MonitorEnter(art::Thread*, art::ObjPtr<art::mirror::Object>, bool)+456) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #04 pc 000000000066c344  /apex/com.android.art/lib64/libart.so (artLockObjectFromCode+32) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #05 pc 000000000012af90  /apex/com.android.art/lib64/libart.so (mterp_op_monitor_enter+16) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #06 pc 00000000003d6544  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.CountlyStore.addEvent)
    #07 pc 0000000000682078  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtualRange+1132) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #08 pc 000000000012db14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual_range+20) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #09 pc 00000000003dc308  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.EventQueue.recordEvent+88)
    #10 pc 0000000000682078  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtualRange+1132) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #11 pc 000000000012db14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual_range+20) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #12 pc 00000000003e0128  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.ModuleEvents.recordEventInternal+1112)
    #13 pc 0000000000682078  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtualRange+1132) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #14 pc 000000000012db14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual_range+20) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #15 pc 00000000003df700  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.ModuleEvents$Events.recordEvent+128)
    #16 pc 0000000000682078  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtualRange+1132) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #17 pc 000000000012db14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual_range+20) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #18 pc 00000000003df654  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.ModuleEvents$Events.recordEvent+24)
    #19 pc 0000000000682078  /apex/com.android.art/lib64/libart.so (MterpInvokeVirtualRange+1132) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #20 pc 000000000012db14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual_range+20) (BuildId: 4bd97125c4572d21b4e97670ee87769f)
    #21 pc 00000000003df60e  /data/app/~~IwrC0tiqyhVYu2IUXk6AHA==/com.bmwgroup.idnext.china.navigation-bG345unRYsgwujP7dSe-0Q==/base.apk (offset 0x4884000) (ly.count.android.sdk.ModuleEvents$Events.recordEvent+22)
in the call stack of thread-2, counly has below lock sequence:

ly.count.android.sdk.EventQueue.recordEvent -> lock Countly 

ly.count.android.sdk.CountlyStore.addEvent -> lock CountlyStore


seems there is a deadlock between thread-1 and thread-2

 

0

Comments

3 comments
  • Hey how are you doing?

    To better help you, could you please inform us:

    1- which SDK version you're using?

    2- how often does this happen?

    3- Is it the first time it happens or there are others?

    4- Were you able to reproduce it?

    0
    Comment actions Permalink
  • Hi,

    Thanks for quick response. We are using version "20.11.8", this is a random issue, not easy to reproduce, we have encountered it on two different devices. But when it occurs, it will make the app ANR continuously when app start, until we delete the app and re-install it.

    In my post, I have found the root cause and highlighted the code which caused the deadlock, please help to check it and fix it, thank you.

    in the call stack of thread-1, counly has below lock sequence:

    ly.count.android.sdk.CountlyStore.addConnection -> lock CountlyStore
    ly.count.android.sdk.Countly.isLoggingEnabled -> lock Countly

    in the call stack of thread-2, counly has below lock sequence:

    ly.count.android.sdk.EventQueue.recordEvent -> lock Countly 
    ly.count.android.sdk.CountlyStore.addEvent -> lock CountlyStore

     

    0
    Comment actions Permalink
  • Hi Hongyu,

     

    Thank you for your patience.

     

    Our eng team is preparing a new Android SDK release, and it should either fix or alleviate this issue. The ETA is in two weeks. (Please check the changelog once we release it; it might have some major changes)

    0
    Comment actions Permalink

Please sign in to leave a comment.