Skip to content

randomUUID generation results in ApplicationNotResponding error from the SDK #4057

@rodolfoBee

Description

@rodolfoBee

Integration

sentry-android

Build System

Gradle

AGP Version

NA

Proguard

Disabled

Version

7.18.0

Steps to Reproduce

Steps to reproduce are unclear.
A way to reproduce would be to by drawing a lot of randomness via secureRandom() until it starts blocking. But that might take a while.

Expected Result

The SDK is able to generate UUID without blocking the main thread.

Actual Result

The Sentry SDK causes an ANR error, here is the stack trace.

io.sentry.android.core.ApplicationNotResponding: ANR
    atsyscall
    atart::ConditionVariable::WaitHoldingLocks(art::Thread*)
    atart::JNI<false>::ReleaseByteArrayElements(_JNIEnv*, _jbyteArray*, signed char*, int)
    atdeleted) (offset 2000000) (art_jni_trampoline
    atdeleted) (offset 2000000) (com.android.org.conscrypt.OpenSSLRandom.engineNextBytes
    at com.android.org.conscrypt.NativeCrypto.RAND_bytes
    at com.android.org.conscrypt.OpenSSLRandom.engineNextBytes(OpenSSLRandom.java:46)
    at java.security.SecureRandom.nextBytes(SecureRandom.java:480)
    at java.util.UUID.randomUUID(UUID.java:145)
    at io.sentry.protocol.SentryId.<init>(SentryId.java:25)
    at io.sentry.protocol.SentryId.<init>(SentryId.java:20)
    at io.sentry.SentryEvent.<init>(SentryEvent.java:102)
    at io.sentry.android.timber.SentryTimberTree.captureEvent(SentryTimberTree.kt:262)
    at io.sentry.android.timber.SentryTimberTree.logWithSentry(SentryTimberTree.kt:240)
    at io.sentry.android.timber.SentryTimberTree.e(SentryTimberTree.kt:146)
    at timber.log.Timber$Forest.e(Timber.kt:342)
    at timber.log.Timber.e(Timber.kt)
    at me.getreach.setup.MainActivity$onCreate$3.invokeSuspend(MainActivity.kt:422)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:28)
    at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:99)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
    at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:65)
    at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined(DispatchedTask.kt:241)
    at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:159)
    at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:470)
    at kotlinx.coroutines.CancellableContinuationImpl.cancel(CancellableContinuationImpl.kt:213)
    at kotlinx.coroutines.CancellableContinuationImpl.parentCancelled$kotlinx_coroutines_core(CancellableContinuationImpl.kt:220)
    at kotlinx.coroutines.ChildContinuation.invoke(JobSupport.kt:1447)
    at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1473)
    at kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:796)
    at kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:756)
    at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:672)
    at kotlinx.coroutines.JobSupport.parentCancelled(JobSupport.kt:638)
    at kotlinx.coroutines.ChildHandleNode.invoke(JobSupport.kt:1436)
    at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1473)
    at kotlinx.coroutines.JobSupport.tryMakeCancelling(JobSupport.kt:796)
    at kotlinx.coroutines.JobSupport.makeCancelling(JobSupport.kt:756)
    at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:672)
    at kotlinx.coroutines.JobSupport.parentCancelled(JobSupport.kt:638)
    at kotlinx.coroutines.ChildHandleNode.invoke(JobSupport.kt:1436)
    at kotlinx.coroutines.JobSupport.notifyCancelling(JobSupport.kt:1473)
    at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:901)
    at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:864)
    at kotlinx.coroutines.JobSupport.cancelMakeCompleting(JobSupport.kt:697)
    at kotlinx.coroutines.JobSupport.cancelImpl$kotlinx_coroutines_core(JobSupport.kt:668)
    at kotlinx.coroutines.JobSupport.cancelInternal(JobSupport.kt:633)
    at kotlinx.coroutines.JobSupport.cancel(JobSupport.kt:618)
    at kotlinx.coroutines.JobKt__JobKt.cancel(Job.kt:560)
    at kotlinx.coroutines.JobKt.cancel(unavailable:1)
    at kotlinx.coroutines.JobKt__JobKt.cancel$default(Job.kt:559)
    at kotlinx.coroutines.JobKt.cancel$default(unavailable:1)
    at androidx.lifecycle.LifecycleCoroutineScopeImpl.onStateChanged(Lifecycle.kt:430)
    at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:322)
    at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.kt:273)
    at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.kt:290)
    at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.kt:143)
    at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.kt:126)
    at androidx.lifecycle.ReportFragment$Companion.dispatch$lifecycle_runtime_release(ReportFragment.kt:190)
    at androidx.lifecycle.ReportFragment$LifecycleCallbacks.onActivityPreDestroyed(ReportFragment.kt:146)
    at android.app.Activity.dispatchActivityPreDestroyed(Activity.java:1498)
    at android.app.Activity.performDestroy(Activity.java:8235)
    at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1344)
    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5094)
    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5139)
    at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7664)
    at java.lang.reflect.Method.invoke
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:952)

A possible root cause of the error is the kerner running out of entropy: https://stackoverflow.com/questions/19981189/how-does-the-kernel-entropy-pool-work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Done

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions