{"action":"created","issue":{"url":"https://api.github.com/repos/JetBrains/kotlin-native/issues/3259","repository_url":"https://api.github.com/repos/JetBrains/kotlin-native","labels_url":"https://api.github.com/repos/JetBrains/kotlin-native/issues/3259/labels{/name}","comments_url":"https://api.github.com/repos/JetBrains/kotlin-native/issues/3259/comments","events_url":"https://api.github.com/repos/JetBrains/kotlin-native/issues/3259/events","html_url":"https://github.com/JetBrains/kotlin-native/issues/3259","id":481875654,"node_id":"MDU6SXNzdWU0ODE4NzU2NTQ=","number":3259,"title":"Memory.cpp:770: runtime assert: Must be positive","user":{"login":"d-r-q","id":1336130,"node_id":"MDQ6VXNlcjEzMzYxMzA=","avatar_url":"https://avatars0.githubusercontent.com/u/1336130?v=4","gravatar_id":"","url":"https://api.github.com/users/d-r-q","html_url":"https://github.com/d-r-q","followers_url":"https://api.github.com/users/d-r-q/followers","following_url":"https://api.github.com/users/d-r-q/following{/other_user}","gists_url":"https://api.github.com/users/d-r-q/gists{/gist_id}","starred_url":"https://api.github.com/users/d-r-q/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d-r-q/subscriptions","organizations_url":"https://api.github.com/users/d-r-q/orgs","repos_url":"https://api.github.com/users/d-r-q/repos","events_url":"https://api.github.com/users/d-r-q/events{/privacy}","received_events_url":"https://api.github.com/users/d-r-q/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2019-08-17T11:14:59Z","updated_at":"2019-10-08T20:46:11Z","closed_at":"2019-09-02T06:56:28Z","author_association":"NONE","body":"Hello, I'm developing android+ios application using kotlin multplatfrom and occasionally get `runtime assert: Must be positive` error in different parts of ios application.\r\n\r\nStacktrace is different each time, but here is an example:\r\n```\r\n* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT\r\n    frame #0: 0x000000010d2f5b66 libsystem_kernel.dylib`__pthread_kill + 10\r\n    frame #1: 0x000000010d32f080 libsystem_pthread.dylib`pthread_kill + 333\r\n    frame #2: 0x000000010d0a2c45 libsystem_c.dylib`abort + 127\r\n    frame #3: 0x0000000107707c99 SharedCode`konan::abort() + 9\r\n    frame #4: 0x0000000107707bb3 SharedCode`RuntimeAssertFailed(char const*, char const*) + 115\r\n    frame #5: 0x000000010770a04a SharedCode`processDecrements(MemoryState*) + 506\r\n    frame #6: 0x000000010770867e SharedCode`garbageCollect(MemoryState*, bool) + 222\r\n    frame #7: 0x000000010770daba SharedCode`AllocInstance + 426\r\n  * frame #8: 0x000000010756e890 SharedCode`kfun:kotlin.collections.AbstractList.iterator(<this>=0x0000600001060148)kotlin.collections.Iterator<#GENERIC> at AbstractList.kt:24\r\n    frame #9: 0x000000010757350a SharedCode`kfun:kotlin.text.findAnyOf#internal [inlined] kfun:kotlin.collections.firstOrNull@kotlin.collections.Iterable<#GENERIC>.(kotlin.Function1<#GENERIC,kotlin.Boolean>)Generic at _Collections.kt:240\r\n    frame #10: 0x00000001075734e9 SharedCode`kfun:kotlin.text.findAnyOf#internal(<this>=0x0000000107816de0, strings=0x0000600001060148, startIndex=202, ignoreCase=false, last=false) at Strings.kt:1146\r\n    frame #11: 0x0000000107573202 SharedCode`kfun:kotlin.text.rangesDelimitedBy$lambda-1#internal(<this>=0x0000000107816de0, delimitersList=0x0000600001060148, ignoreCase=false, currentIndex=202) at Strings.kt:1167\r\n    frame #12: 0x0000000107573136 SharedCode`kfun:kotlin.text.$rangesDelimitedBy$lambda-1$FUNCTION_REFERENCE$175.invoke#internal(<this>=0x0000600001061e48, p1=4420890080, p2=105553133470312) at Strings.kt:1167\r\n    frame #13: 0x0000000107572af5 SharedCode`kfun:kotlin.text.DelimitedRangesSequence.object-1.calcNext#internal(<this>=0x00006000004f1608) at Strings.kt:1095\r\n    frame #14: 0x00000001075726af SharedCode`kfun:kotlin.text.DelimitedRangesSequence.object-1.hasNext#internal(<this>=0x00006000004f1608) at Strings.kt:1124\r\n    frame #15: 0x0000000107571c28 SharedCode`kfun:kotlin.sequences.TransformingSequence.object-1.hasNext#internal(<this>=0x0000600001060488) at Sequences.kt:176\r\n    frame #16: 0x000000010757152b SharedCode`kfun:kotlin.sequences.toCollection@kotlin.sequences.Sequence<#GENERIC>.(<this>=0x00006000010603c8, destination=105553149644744)Generic at _Sequences.kt:702\r\n    frame #17: 0x000000010756e006 SharedCode`kfun:kotlin.sequences.toMutableList@kotlin.sequences.Sequence<#GENERIC>.(<this>=0x00006000010603c8)Generic at _Sequences.kt:732\r\n    frame #18: 0x000000010756df48 SharedCode`kfun:kotlin.sequences.toList@kotlin.sequences.Sequence<#GENERIC>.(<this>=0x00006000010603c8)Generic at _Sequences.kt:723\r\n    frame #19: 0x000000010756c9a4 SharedCode`kfun:kotlin.text.lines@kotlin.CharSequence.(<this>=0x0000000107816de0)kotlin.collections.List<kotlin.String> at Strings.kt:1287\r\n    frame #20: 0x000000010756c403 SharedCode`kfun:kotlin.text.replaceIndent@kotlin.String.(<this>=0x0000000107816de0, newIndent=0x00000001077b5a98)kotlin.String at Indent.kt:69\r\n    frame #21: 0x000000010756c353 SharedCode`kfun:kotlin.text.trimIndent@kotlin.String.(<this>=0x0000000107816de0)kotlin.String at Indent.kt:63\r\n    frame #22: 0x000000010760a67c SharedCode`kfun:com.finagregator.udobno.banks.ProductsRepository.$<init>$<no name provided>$fillForm$lambda-119$lambda-109COROUTINE$97.invokeSuspend#internal(<this>=0x00006000004f0108, result=0x00000001077b0cf8) at ProductsRepository.kt:1020\r\n    frame #23: 0x000000010760a833 SharedCode`kfun:com.finagregator.udobno.banks.ProductsRepository.$<init>$<no name provided>$fillForm$lambda-119$lambda-109COROUTINE$97.invoke#internal(<this>=0x0000600000ba2748) at ProductsRepository.kt:1010\r\n    frame #24: 0x00000001075fcfca SharedCode`kfun:com.finagregator.udobno.webapplying.Script.$runCOROUTINE$127.invokeSuspend(<this>=0x0000600003a2ec38, result=0x0000600001060008)kotlin.Any? at scripts.kt:66\r\n    frame #25: 0x000000010754f835 SharedCode`kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) [inlined] <inlined-out:<anonymous>> at ContinuationImpl.kt:30\r\n    frame #26: 0x000000010754f7e7 SharedCode`kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) [inlined] kfun:kotlin.with(#GENERIC;kotlin.Function1<#GENERIC,#GENERIC>)Generic at Standard.kt:53\r\n    frame #27: 0x000000010754f7e7 SharedCode`kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(<this>=0x00006000004edd88, result=0x0000600001060008) at ContinuationImpl.kt:26\r\n    frame #28: 0x0000000107553fc0 SharedCode`kfun:kotlinx.coroutines.DispatchedTask.run() [inlined] kfun:kotlin.coroutines.resume@kotlin.coroutines.Continuation<#GENERIC>.(#GENERIC)Generic at Continuation.kt:44\r\n    frame #29: 0x0000000107553f9f SharedCode`kfun:kotlinx.coroutines.DispatchedTask.run() [inlined] <inlined-out:<anonymous>> at Dispatched.kt:158\r\n    frame #30: 0x0000000107553f9f SharedCode`kfun:kotlinx.coroutines.DispatchedTask.run() [inlined] kfun:kotlinx.coroutines.withCoroutineContext$kotlinx-coroutines-core(kotlin.coroutines.CoroutineContext;kotlin.Any?;kotlin.Function0<#GENERIC>)Generic at CoroutineContext.kt:57\r\n    frame #31: 0x0000000107553f9f SharedCode`kfun:kotlinx.coroutines.DispatchedTask.run(<this>=0x00006000004ed2c8) at Dispatched.kt:158\r\n    frame #32: 0x0000000107663470 SharedCode`kfun:com.finagregator.udobno.platform.MainDispatcher.dispatch$lambda-0#internal(block=0x00006000004ed2c8) at Coroutines.kt:48\r\n    frame #33: 0x0000000107663415 SharedCode`kfun:com.finagregator.udobno.platform.MainDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$42.invoke#internal(<this>=0x0000600001060268) at Coroutines.kt:46\r\n    frame #34: 0x00000001076633e5 SharedCode`kfun:com.finagregator.udobno.platform.MainDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$42.$<bridge-UNN>invoke(<this>=0x0000600001060268)#internal at Coroutines.kt:46\r\n    frame #35: 0x00000001077070da SharedCode`platform_darwin_kniBridge202(p0=0x0000600001060220) at darwin.kt:24531\r\n    frame #36: 0x0000000107723ae9 SharedCode`__platform_darwin_kniBridge201_block_invoke + 25\r\n    frame #37: 0x000000010cf3f595 libdispatch.dylib`_dispatch_call_block_and_release + 12\r\n    frame #38: 0x000000010cf40602 libdispatch.dylib`_dispatch_client_callout + 8\r\n    frame #39: 0x000000010cf4d99a libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1541\r\n    frame #40: 0x0000000108e903e9 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9\r\n    frame #41: 0x0000000108e8aa76 CoreFoundation`__CFRunLoopRun + 2342\r\n    frame #42: 0x0000000108e89e11 CoreFoundation`CFRunLoopRunSpecific + 625\r\n    frame #43: 0x00000001131c11dd GraphicsServices`GSEventRunModal + 62\r\n    frame #44: 0x000000010f88b81d UIKitCore`UIApplicationMain + 140\r\n    frame #45: 0x000000010710e0d7 udobno`main at AppDelegate.swift:12\r\n    frame #46: 0x000000010cfb6575 libdyld.dylib`start + 1\r\n```\r\n\r\nI can easily reproduce the problem on 1.3.41 and 1.3.50-eap-86. For example  it can appear after tens-hundreds iterations of a loop that actually do the same thing (execute the same code in a WebView and print few lines to console) on each iteration.\r\n\r\nI'm not experienced swift developer, so I suspect, that this problem may be caused by bug (memory leak?) in my code - how can I determine what is actual cause of the problem?"},"comment":{"url":"https://api.github.com/repos/JetBrains/kotlin-native/issues/comments/539697084","html_url":"https://github.com/JetBrains/kotlin-native/issues/3259#issuecomment-539697084","issue_url":"https://api.github.com/repos/JetBrains/kotlin-native/issues/3259","id":539697084,"node_id":"MDEyOklzc3VlQ29tbWVudDUzOTY5NzA4NA==","user":{"login":"FrancoSabadini","id":5099645,"node_id":"MDQ6VXNlcjUwOTk2NDU=","avatar_url":"https://avatars1.githubusercontent.com/u/5099645?v=4","gravatar_id":"","url":"https://api.github.com/users/FrancoSabadini","html_url":"https://github.com/FrancoSabadini","followers_url":"https://api.github.com/users/FrancoSabadini/followers","following_url":"https://api.github.com/users/FrancoSabadini/following{/other_user}","gists_url":"https://api.github.com/users/FrancoSabadini/gists{/gist_id}","starred_url":"https://api.github.com/users/FrancoSabadini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FrancoSabadini/subscriptions","organizations_url":"https://api.github.com/users/FrancoSabadini/orgs","repos_url":"https://api.github.com/users/FrancoSabadini/repos","events_url":"https://api.github.com/users/FrancoSabadini/events{/privacy}","received_events_url":"https://api.github.com/users/FrancoSabadini/received_events","type":"User","site_admin":false},"created_at":"2019-10-08T20:46:11Z","updated_at":"2019-10-08T20:46:11Z","author_association":"NONE","body":"Yes, I'm trying that now @SvyatoslavScherbina. I will let you know if I still see the issue with that workaround.\r\n\r\nI compared the implementations of `Memory.cpp` in versions 1.3.41 and 1.3.50 and seems like the crash happens on the same line so I believe this is the same issue."}}
{"actor":{"display_login":"FrancoSabadini"}}