We are getting crashes with kotlin 2.0.21 on iOS d...
# ios
l
We are getting crashes with kotlin 2.0.21 on iOS devices. This happens when calling regex.find. here is the regex
val regex = Regex("""(\(\w+\.kt:\d+\))|((\w|-)+\.wasm:wasm-function\[\d+]:0x[a-f0-9]+|kfun:(\w|-)+#\w+\(.*\))""")
. We are trying to parse the exception stack trace. I cannot reproduce this crash in iosSimulatorArm64Test, but I have a lldb debugger in xcode attached. The input to the regex looks something like:
Copy code
RuntimeException: Failed to update catalogs
Caused by: FileNotFoundException: No such file or directory
0   VoizeTIC.debug.dylib                0x113b81bf7        kfun:kotlin.Exception#<init>(kotlin.String?;kotlin.Throwable?){} + 143 
1   VoizeTIC.debug.dylib                0x113b81e17        kfun:kotlin.RuntimeException#<init>(kotlin.String?;kotlin.Throwable?){} + 143 
2   VoizeTIC.debug.dylib                0x112d7a4df        kfun:de.voize.core.shared.util#withContext__at__kotlin.Throwable(kotlin.String){}kotlin.RuntimeException + 147 
3   VoizeTIC.debug.dylib                0x11301fc0f        kfun:de.voize.core.mobile.inspection.catalogs.InspectionCatalogManagerImpl.$updateCatalogsCOROUTINE$0.invokeSuspend#internal + 6767 
4   VoizeTIC.debug.dylib                0x11302021f        kfun:de.voize.core.mobile.inspection.catalogs.InspectionCatalogManagerImpl#updateCatalogs#suspend(kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any + 263 
5   VoizeTIC.debug.dylib                0x1135ad1d3        kfun:de.voize.core.shared.inspection.catalogs.InspectionCatalogManager#updateCatalogs#suspend(kotlin.coroutines.Continuation<kotlin.Unit>){}kotlin.Any-trampoline + 107 
6   VoizeTIC.debug.dylib                0x11302eaeb        kfun:de.voize.core.mobile.inspection.catalogs.InspectionCatalogsWorker.$doWorkCOROUTINE$0.invokeSuspend#internal + 411 
7   VoizeTIC.debug.dylib                0x11302ed07        kfun:de.voize.core.mobile.inspection.catalogs.InspectionCatalogsWorker#doWork#suspend(kotlin.coroutines.Continuation<de.voize.core.mobile.background.WorkerResult>){}kotlin.Any + 263 
8   VoizeTIC.debug.dylib                0x1135bce93        kfun:de.voize.core.mobile.background.Worker#doWork#suspend(kotlin.coroutines.Continuation<de.voize.core.mobile.background.WorkerResult>){}kotlin.Any-trampoline + 107 
9   VoizeTIC.debug.dylib                0x112f6200b        kfun:de.voize.core.mobile.background.$executeWorkCOROUTINE$0.invokeSuspend#internal + 2583 
10  VoizeTIC.debug.dylib                0x113cef423        kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any?-trampoline + 71 
11  VoizeTIC.debug.dylib                0x113b8e807        kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 647 
12  VoizeTIC.debug.dylib                0x113cef50f        kfun:kotlin.coroutines.Continuation#resumeWith(kotlin.Result<1:0>){}-trampoline + 99 
13  VoizeTIC.debug.dylib                0x113e2ca73        kfun:kotlinx.coroutines.DispatchedTask#run(){} + 1695 
14  VoizeTIC.debug.dylib                0x113e5e32b        kfun:kotlinx.coroutines.Runnable#run(){}-trampoline + 91 
15  VoizeTIC.debug.dylib                0x113e587ff        kfun:kotlinx.coroutines.DarwinGlobalQueueDispatcher.dispatch$lambda$0#internal + 119 
16  VoizeTIC.debug.dylib                0x113e5885b        kfun:kotlinx.coroutines.DarwinGlobalQueueDispatcher.$dispatch$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 71 
17  VoizeTIC.debug.dylib                0x113e5892b        kfun:kotlinx.coroutines.DarwinGlobalQueueDispatcher.$dispatch$lambda$0$FUNCTION_REFERENCE$0.$<bridge-DNN>invoke(){}#internal + 71 
18  VoizeTIC.debug.dylib                0x113cec623        kfun:kotlin.Function0#invoke(){}1:0-trampoline + 99 
19  VoizeTIC.debug.dylib                0x113e5a587        _6f72672e6a6574627261696e732e6b6f746c696e783a6b6f746c696e782d636f726f7574696e65732d636f72652f6f70742f6275696c644167656e742f776f726b2f343465633665383530643563363366302f6b6f746c696e782d636f726f7574696e65732d636f72652f6e617469766544617277696e2f7372632f44697370617463686572732e6b74_knbridge8 + 203 
20  libdispatch.dylib                   0x101170a2f        _dispatch_call_block_and_release + 31 
21  libdispatch.dylib                   0x10117271b        _dispatch_client_callout + 19 
22  libdispatch.dylib                   0x101186e57        _dispatch_root_queue_drain + 963 
23  libdispatch.dylib                   0x101187617        _dispatch_worker_thread2 + 187 
24  libsystem_pthread.dylib             0x212f3fc3f        _pthread_wqthread + 227 
25  libsystem_pthread.dylib             0x212f3c487        start_wqthread + 7
1
we have been able to resolve this, by simplifying the regex. Maybe this part of the regex was the problem
(\w|-)+
we replaced it with
[\w-]+
. we also splitt the regex for each individual platform and used an expect/actual function to get the correct regex.