Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack Overflow after 1.2.0, because of shared commit. #1163

Open
Shabinder opened this issue Nov 7, 2023 · 7 comments · May be fixed by #1408
Open

Stack Overflow after 1.2.0, because of shared commit. #1163

Shabinder opened this issue Nov 7, 2023 · 7 comments · May be fixed by #1408

Comments

@Shabinder
Copy link
Contributor

Some Traces thrown from plugins are very opaque on the cause of the crash, or am I missing something here ?

app.cash.zipline.ZiplineException: CompletionHandlerException: Exception in completion handler InvokeOnCompletion@4[job@5] for DeferredCoroutine{Completed}@5
                                                                                                    	at captureStack (runtime/coreRuntime.kt:12)
                                                                                                    	at CompletionHandlerException (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/Exceptions.common.kt:1813)
                                                                                                    	at notifyCompletion (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:158)
                                                                                                    	at completeStateFinalization (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:325)
                                                                                                    	at finalizeFinishingState (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:236)
                                                                                                    	at tryMakeCompletingSlowPath (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:910)
                                                                                                    	at tryMakeCompleting (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:867)
                                                                                                    	at <anonymous> (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:832)
                                                                                                    	at <anonymous> (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/AbstractCoroutine.kt:99)
                                                                                                    	at <anonymous> (src/kotlin/coroutines_13/CoroutineImpl.kt:45)
                                                                                                    	at <anonymous> (kotlin-kotlin-stdlib-js-ir.js)
                                                                                                    	at <anonymous> (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:112)
                                                                                                    	at <anonymous> (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/js/src/JSDispatcher.kt:155)
                                                                                                    	at <anonymous> (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/js/src/JSDispatcher.kt)
                                                                                                    	at apply (native)
                                                                                                    	at <anonymous> (runner/work/zipline/zipline/zipline/src/jsMain/kotlin/app/cash/zipline/GlobalBridge.kt:72)
                                                                                                    	at <anonymous> (runner/work/zipline/zipline/zipline/src/commonMain/kotlin/app/cash/zipline/internal/GuestService.kt)
                                                                                                    	at <anonymous> (zipline-root-zipline.js)
                                                                                                    	at <anonymous> (runner/work/zipline/zipline/zipline/src/commonMain/kotlin/app/cash/zipline/internal/bridge/InboundService.kt:53)
                                                                                                    	at <anonymous> (runner/work/zipline/zipline/zipline/src/commonMain/kotlin/app/cash/zipline/internal/bridge/Endpoint.kt:99)
                                                                                                    	at <anonymous> (zipline-root-zipline.js)
                                                                                                    	at <anonymous> (runner/work/zipline/zipline/zipline/src/jsMain/kotlin/app/cash/zipline/GlobalBridge.kt)
                                                                                                    	at <anonymous> (zipline-root-zipline.js)
                                                                                                        Suppressed: DiagnosticCoroutineContextException: [DeferredCoroutine{Completed}@5, SetTimeoutDispatcher@3]
                                                                                                    	at captureStack (runtime/coreRuntime.kt:12)
                                                                                                    	at DiagnosticCoroutineContextException (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/js/src/internal/CoroutineExceptionHandlerImpl.kt:8709)
                                                                                                    	at handleUncaughtCoroutineException (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/CoroutineExceptionHandlerImpl.common.kt:46)
                                                                                                    	at handleCoroutineException (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/CoroutineExceptionHandler.kt:32)
                                                                                                    	at <anonymous> (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/AbstractCoroutine.kt:107)
                                                                                                    	at notifyCompletion (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:158)
                                                                                                            ... and 21 more common stack frames skipped
                                                                                                    Caused by:     at captureStack (runtime/coreRuntime.kt:12)
                                                                                                    	at ClassCastException_init_$Create$ (kotlin-kotlin-stdlib-js-ir.js)
                                                                                                    	at THROW_CCE (runtime/hacks.kt)
                                                                                                    	at <anonymous> (soundbound-extensions-lib.js)
                                                                                                    	at <anonymous> (opt/buildAgent/work/b2fef8360e1bcf3d/formats/json/commonMain/src/kotlinx/serialization/json/internal/Polymorphic.kt:20)
                                                                                                    	at <anonymous> (opt/buildAgent/work/b2fef8360e1bcf3d/core/commonMain/src/kotlinx/serialization/encoding/AbstractEncoder.kt:80)
                                                                                                    	at <anonymous> (opt/buildAgent/work/b2fef8360e1bcf3d/core/commonMain/src/kotlinx/serialization/internal/CollectionSerializers.kt:68)
                                                                                                    	at <anonymous> (kotlinx-serialization-kotlinx-serialization-core.js)
                                                                                                    	at <anonymous> (opt/buildAgent/work/b2fef8360e1bcf3d/formats/json/commonMain/src/kotlinx/serialization/json/internal/Polymorphic.kt:20)
2023-11-07 23:30:07.725   813-891   Zipline                 in.shabinder.soundbound.preview      E  	at <anonymous> (opt/buildAgent/work/b2fef8360e1bcf3d/core/commonMain/src/kotlinx/serialization/encoding/AbstractEncoder.kt:80)
                                                                                                    	at <anonymous> (commonMainSources/libraries/stdlib/src/kotlin/util/Preconditions.kt:1876)
                                                                                                    	at <anonymous> (zipline-root-zipline.js)
                                                                                                    	at <anonymous> (opt/buildAgent/work/b2fef8360e1bcf3d/formats/json/commonMain/src/kotlinx/serialization/json/internal/Polymorphic.kt:20)
                                                                                                    	at <anonymous> (opt/buildAgent/work/b2fef8360e1bcf3d/core/commonMain/src/kotlinx/serialization/encoding/AbstractEncoder.kt:80)
                                                                                                    	at <anonymous> (opt/buildAgent/work/b2fef8360e1bcf3d/core/commonMain/src/kotlinx/serialization/encoding/Encoding.kt:92)
                                                                                                    	at <anonymous> (zipline-root-zipline.js)
                                                                                                    	at <anonymous> (opt/buildAgent/work/b2fef8360e1bcf3d/formats/json/commonMain/src/kotlinx/serialization/json/internal/Polymorphic.kt:20)
                                                                                                    	at encodeToDynamic_0 (opt/buildAgent/work/b2fef8360e1bcf3d/formats/json/jsMain/src/kotlinx/serialization/json/internal/DynamicEncoders.kt:42)
                                                                                                    	at encodeToDynamic (opt/buildAgent/work/b2fef8360e1bcf3d/formats/json/jsMain/src/kotlinx/serialization/json/Dynamics.kt)
                                                                                                    	at encodeToStringFast (runner/work/zipline/zipline/zipline/src/jsMain/kotlin/app/cash/zipline/internal/jsonJs.kt)
                                                                                                    	at <anonymous> (runner/work/zipline/zipline/zipline/src/commonMain/kotlin/app/cash/zipline/internal/bridge/CallCodec.kt:56)
                                                                                                    	at <anonymous> (runner/work/zipline/zipline/zipline/src/commonMain/kotlin/app/cash/zipline/internal/bridge/OutboundCallHandler.kt:99)
                                                                                                    	at <anonymous> (runner/work/zipline/zipline/zipline/src/commonMain/kotlin/app/cash/zipline/internal/bridge/SuspendCallback.kt)
                                                                                                    	at <anonymous> (zipline-root-zipline.js)
                                                                                                    	at <anonymous> (runner/work/zipline/zipline/zipline/src/commonMain/kotlin/app/cash/zipline/internal/bridge/InboundService.kt:53)
                                                                                                    	at <anonymous> (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt)
                                                                                                    	at <anonymous> (kotlinx.coroutines-kotlinx-coroutines-core-js-ir.js)
                                                                                                    	at notifyCompletion (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:369)
                                                                                                    	at completeStateFinalization (mnt/agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:325)
                                                                                                        ... and 20 more common stack frames skipped
                                                                                                    	at app.cash.zipline.internal.GuestService$Companion$Adapter$GeneratedOutboundService.runJob(GuestService.kt:23)
                                                                                                    	at app.cash.zipline.internal.CoroutineEventLoop$DelayedJob$run$1.invokeSuspend(CoroutineEventLoop.kt:61)
                                                                                                    	at app.cash.zipline.internal.CoroutineEventLoop$DelayedJob$run$1.invoke(Unknown Source:8)
                                                                                                    	at app.cash.zipline.internal.CoroutineEventLoop$DelayedJob$run$1.invoke(Unknown Source:4)
                                                                                                    	at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:44)
                                                                                                    	at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:112)
                                                                                                    	at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
                                                                                                    	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
                                                                                                    	at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
                                                                                                    	at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
                                                                                                    	at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
                                                                                                    	at app.cash.zipline.internal.CoroutineEventLoop$DelayedJob.run(CoroutineEventLoop.kt:58)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
@Shabinder
Copy link
Contributor Author

image

@Shabinder
Copy link
Contributor Author

@Shabinder
Copy link
Contributor Author

Shabinder commented Mar 15, 2024

Any update ?

have been stuck on kotlin 1.9.10 and zipline 1.2.0, since above doesnt work. I am more than happy to provide info in any way possible or do a brief sync explaining the steps to repro same.

Case 1: ✅

  • Using zipline 1.2.0 host and jsSource both works fine.

Case 2: 🔴

  • used zipline 1.8.0 in host(android) and jsSources built with 1.2.0: StackOverflow (looped on below trace)
    • ZiplineServiceAdapterKt.descriptorName refer below image for full trace
      - So this breaks the promise done in readme for 1.x host and binary compatibility ⚠️
      image

Case 3: 🔴

  • used zipine 1.8.0 for both host and runtime jsBinaries, gave below hard crash
    • Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7b7f130ff8 in tid 30292 (DefaultDispatch), pid 30209 (ndbound.preview) refer below image for full trace
image

@Shabinder
Copy link
Contributor Author

After many iteration on finding out what works and what doesnt,

Below Commit is what makes the difference, with commit, plugins are loaded as expected, without, get stackOverflow error as shown.

Shabinder@801b3d6

Shortlisted as much as I could, lmk if I can help or diagnose it more in any other way

@Shabinder Shabinder changed the title Non Descriptive Crash Traces. Stack Overflow after 1.2.0, because of shared commit. Apr 29, 2024
@JakeWharton
Copy link
Collaborator

So it seems like a type with a recursive descriptor. We can change the calculation to put in a placeholder character for when it recurses by keeping a set of seen types. Will have to try and reproduce, but should be pretty easy give what you've found out so far.

@minteemer
Copy link

minteemer commented Jul 3, 2024

Got the same exception when using JsonElement as return type of a suspending ZiplineService method:

interface ExampleService : ZiplineService {

  suspend fun example(): JsonElement
}

JsonElement might be JsonArray or JsonObject, which in turn contains List<JsonElement> or Map<String, JsonElement>, thus recursion appears.
A big problem for us, as we wanted to use JsonElement as a return type to get abstract tree of analytics params this way.

This exception does not seem to appear when using JsonElement in return type of non-suspending functions or when using it in function parameters.

@Shabinder
Copy link
Contributor Author

@JakeWharton your hunch was r8, took time and dug in more today:

this is the class which ends in endless recursion

in.shabinder.soundbound.models.ThrowableWrapper(
message: kotlin.String, 
stackTrace: kotlin.String,
cause: in.shabinder.soundbound.models.ThrowableWrapper?
)?
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants