Skip to content

TypeCastException in KeychainSettings.keys during clear() #243

@Skeptick

Description

@Skeptick

We've seen a single production crash during a migration from KeychainSettings to DataStore. The crash happens while running migration cleanup, when calling clear().

Kotlin: 2.3.10
Coroutines: 1.10.2
multiplatform-settings: 1.3.0

Fatal Exception: kotlin.TypeCastException
ThrowTypeCastException + 54 (RuntimeUtils.kt:54)
kfun:com.russhwolf.settings.KeychainSettings#<get-keys>(){}kotlin.collections.Set<kotlin.String> + 154 (KeychainSettings.kt:154)
kfun:com.russhwolf.settings.KeychainSettings#clear(){} + 1915 (_Collections.kt:1915)
kfun:com.russhwolf.settings.coroutines.SuspendSettingsWrapper.SuspendSettingsWrapper$clear$2.invoke#internal + 52 (Converters.kt:52)
kfun:kotlinx.coroutines.intrinsics.startUndspatched#internal + 1 ([K][Suspend]Functions:1)
kfun:kotlinx.coroutines#withContext#suspend(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,0:0>;kotlin.coroutines.Continuation<0:0>){0§<kotlin.Any?>}kotlin.Any? + 157 (Builders.common.kt:157)
kfun:com.russhwolf.settings.coroutines.SuspendSettingsWrapper.clear#internal + 52 (Converters.kt:52)
kfun:com.example.CommonDataMigration#cleanUp#suspend(kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any + 41 (PreferencesMigration.common.kt:41)
kfun:androidx.datastore.core.DataMigrationInitializer.Companion.DataMigrationInitializer$Companion$runMigrations$2.DataMigrationInitializer$Companion$runMigrations$2$invoke$$inlined$fold$1.invoke#internal + 67 (_Collections.kt:67)
kfun:androidx.datastore.core.DataMigrationInitializer.Companion.$runMigrationsCOROUTINE$1.invokeSuspend#internal + 1 ([K][Suspend]Functions:1)
kfun:androidx.datastore.core.DataMigrationInitializer.Companion.DataMigrationInitializer$Companion$getInitializer$1.invoke#internal + 66 (DataMigrationInitializer.kt:66)
kfun:androidx.datastore.core.DataStoreImpl.InitDataStore.DataStoreImpl$InitDataStore$doRun$initData$1.$invokeCOROUTINE$1.invokeSuspend#internal + 1 ([K][Suspend]Functions:1)
kfun:androidx.datastore.core.DataStoreImpl.InitDataStore.DataStoreImpl$InitDataStore$doRun$initData$1.invoke#internal + 488 (DataStoreImpl.kt:488)
kfun:androidx.datastore.core.SingleProcessCoordinator.$lockCOROUTINE$0.invokeSuspend#internal + 1 ([K][Suspend]Functions:1)
kfun:androidx.datastore.core.SingleProcessCoordinator#lock#suspend(kotlin.coroutines.SuspendFunction0<0:0>;kotlin.coroutines.Continuation<0:0>){0§<kotlin.Any?>}kotlin.Any? + 41 (SingleProcessCoordinator.kt:41)
kfun:androidx.datastore.core.DataStoreImpl.InitDataStore.$doRunCOROUTINE$2.invokeSuspend#internal + 46 (InterProcessCoordinator.kt:46)
kfun:androidx.datastore.core.DataStoreImpl.InitDataStore.doRun#internal + 491 (DataStoreImpl.kt:491)
kfun:androidx.datastore.core.RunOnce.$runIfNeededCOROUTINE$22.invokeSuspend#internal + 509 (DataStoreImpl.kt:509)
kfun:androidx.datastore.core.DataStoreImpl.$readAndInitOrPropagateAndThrowFailureCOROUTINE$18.invokeSuspend#internal + 513 (DataStoreImpl.kt:513)
kfun:androidx.datastore.core.DataStoreImpl.readAndInitOrPropagateAndThrowFailure#internal + 291 (DataStoreImpl.kt:291)
kfun:androidx.datastore.core.DataStoreImpl.DataStoreImpl$readState$2.$invokeCOROUTINE$6.invokeSuspend#internal + 232 (DataStoreImpl.kt:232)
kfun:androidx.datastore.core.DataStoreImpl.DataStoreImpl$readState$2.invoke#internal + 242 (DataStoreImpl.kt:242)
kfun:kotlin.coroutines.intrinsics.createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$2.invokeSuspend#internal (IntrinsicsNative.kt)
kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 50 (ContinuationImpl.kt:50)
kfun:kotlinx.coroutines.DispatchedTask#run(){} + 109 (DispatchedTask.kt:109)
kfun:kotlinx.coroutines.internal.LimitedDispatcher.Worker.run#internal + 128 (LimitedDispatcher.kt:128)
kfun:kotlinx.coroutines.MultiWorkerDispatcher.MultiWorkerDispatcher$workerRunLoop$1.$invokeCOROUTINE$0.invokeSuspend#internal + 12 (Runnable.kt:12)
kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 50 (ContinuationImpl.kt:50)
kfun:kotlinx.coroutines.DispatchedTask#run(){} + 109 (DispatchedTask.kt:109)
kfun:kotlinx.coroutines.EventLoopImplBase#processNextEvent(){}kotlin.Long + 15 (ObjectiveCUtils.kt:15)
kfun:kotlinx.coroutines#runBlocking(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,0:0>){0§<kotlin.Any?>}0:0 + 49 (EventLoop.common.kt:49)
kfun:kotlinx.coroutines.MultiWorkerDispatcher.MultiWorkerDispatcher$1.MultiWorkerDispatcher$1$invoke$$inlined$apply$1.$<bridge-DN>invoke(){}#internal + 123 (MultithreadedDispatchers.kt:123)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions