Skip to content

Crashed: GC_is_marked for IOS #154

Open

Description

@jungukang-dev

I'm experiencing an iOS crash issue in v1.11.0 ~ v1.11.2. Looking at the changelog for v1.11.3~v1.11.4, it's clear this bug likely hasn't been fixed.
I am using Unity 2022.3.62f2 and using Incremental GC. I would be grateful if you could confirm.

Below are the error details (using v1.11.2)

Crashed: tokio-runtime-worker
0 UnityFramework 0x1989e3c GC_is_marked + 242 (mark.c:242)
1 UnityFramework 0xbd5cc00 push_ephemerons(GC_ms_entry*, GC_ms_entry*) + 662 (BoehmGC.cpp:662)
2 UnityFramework 0x1987c5c GC_mark_some + 405 (mark.c:405)
3 UnityFramework 0x1987260 GC_stopped_mark + 833 (alloc.c:833)
4 UnityFramework 0x1986cf8 GC_try_to_collect_inner + 580 (alloc.c:580)
5 UnityFramework 0x19828b0 GC_init + 1309 (misc.c:1309)
6 UnityFramework 0x1982fb8 GC_generic_malloc_inner + 175 (malloc.c:175)
7 UnityFramework 0x1982cc4 GC_gcj_malloc + 147 (gcj_mlc.c:147)
8 UnityFramework 0xbd90140 il2cpp::vm::Object::NewAllocSpecific(Il2CppClass*) + 82 (Object.cpp:82)
9 UnityFramework 0xbda87dc il2cpp::vm::Thread::Attach(Il2CppDomain*) + 153 (Thread.cpp:153)
10 UnityFramework 0xbda877c il2cpp::vm::ScopedThreadAttacher::ScopedThreadAttacher() + 15 (ScopedThreadAttacher.cpp:15)
11 UnityFramework 0x3e4e67c ReversePInvokeWrapper_NativeHttpHandlerCore_OnReceive_m4158FC4532267FECFEEF3143942621775F2DA961 + 3964 (Cysharp.Net.Http.YetAnotherHttpHandler.cpp:3964)
12 UnityFramework 0xb8e4dbc yaha_native::binding::yaha_request_begin::_$u7b$$u7b$closure$u7d$$u7d$::h2b7e6909f781913f + 5980
13 UnityFramework 0xb8e0720 tokio::runtime::task::harness::Harness$LT$T$C$S$GT$::poll::h7b92a6cd8b60b97c + 404984
14 UnityFramework 0xba47350 tokio::runtime::scheduler::multi_thread::worker::Context::run_task::h7380ac8088d2521f + 596
15 UnityFramework 0xba44d5c tokio::runtime::context::scoped::Scoped$LT$T$GT$::set::he6d0c6622b0923ca + 640
16 UnityFramework 0xba4129c tokio::runtime::context::runtime::enter_runtime::hc727493226e38c0b + 516
17 UnityFramework 0xba4708c tokio::runtime::scheduler::multi_thread::worker::run::hbd73f82e5169ac5a + 104
18 UnityFramework 0xba501bc tokio::runtime::task::core::Core$LT$T$C$S$GT$::poll::h5323d7e8693b7ffc + 3652
19 UnityFramework 0xba25a34 tokio::runtime::task::harness::Harness$LT$T$C$S$GT$::poll::h3911bee5cfacc862 + 7076
20 UnityFramework 0xba388dc tokio::runtime::blocking::pool::Inner::run::h7cb65a1b877c1f56 + 1604
21 UnityFramework 0xba3b164 std::sys::backtrace::__rust_begin_short_backtrace::ha559214fb74c3691 + 192
22 UnityFramework 0xba3ba34 core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h902e9e781817c27d + 1864
23 UnityFramework 0xbad31f4 std::sys::pal::unix::thread::Thread::new::thread_start::h45a7f62b02ec0fe0 + 395 (mod.rs:395)
24 libsystem_pthread.dylib 0x444c _pthread_start + 136
25 libsystem_pthread.dylib 0x8cc thread_start + 8

Activity

  1. ericmsauer commented on Jan 21, 2026

    @ericmsauer

    We hit this issue as well. Were you able to resolve your issue?

    YAHH: 1.11.4
    Unity: 6.0.58f2

    We believe it might have to do with some il2cpp stripping, did you add these libraries to your link.xml?

  2. PawelMilaszewicz commented on Sep 1, 2026

    @PawelMilaszewicz

    We're hitting this same crash in production on YetAnotherHttpHandler 1.11.4, Unity 6000.3.17f1, iOS 26.x. It's the top iOS fatal in our app (that does gRPC over HTTP/2).

    Our variant faults one frame earlier than the GC allocation in the original report, but it's the same thread-attach on the tokio worker:

    Crashed: tokio-runtime-worker
    0  pthread_getspecific
    1  il2cpp::vm::ScopedThreadAttacher::ScopedThreadAttacher()  (ScopedThreadAttacher.cpp:10)
    2  ReversePInvokeWrapper.NativeHttpHandlerCore_OnReceive     (Cysharp.Net.Http.YetAnotherHttpHandler.cpp)
    3  yaha_native::binding::yaha_request_begin::{{closure}}
       … tokio multi_thread worker → blocking::pool::Inner::run …
    

    Both stacks are NativeHttpHandlerCore_OnReceive → ScopedThreadAttacher; #154 faults inside the GC allocation that Thread::Attach performs, ours in the pthread_getspecific right before it. Same root: a tokio worker invokes the OnReceive reverse-P/Invoke and il2cpp attaches the native thread while the app is backgrounding.

    Trigger, from breadcrumbs (100% processState: BACKGROUND, consistent with #142):

    • The crash fires ~1 second after OnApplicationPause(true) (app sent to background), while there is in-flight HTTP/2 activity — often right after a reconnect, when YAHA is completing failed requests.

    Things we tried that did not fix it (corroborating @utkayd in #142 that pausing/resuming is ineffective):

    • On background we Dispose() the YetAnotherHttpHandler, which drops the last ref so NativeRuntime is released and yaha_dispose_runtime runs. This removed a batch of related ObjectDisposedExceptions but did not eliminate this fatal.
    • We think that's because yaha_dispose_runtime is a plain, unbounded Runtime drop performed on the main thread during OnApplicationPause: it can't interrupt a worker already inside the OnReceive callback, and iOS can suspend the process before the drop finishes joining the workers.

    The core issue seems to be that the OnReceive/OnComplete reverse-P/Invoke callbacks attach a thread and allocate through the GC, which isn't safe while iOS is suspending the process. Two things that would help from the library side:

    1. A bounded runtime shutdown (e.g. Runtime::shutdown_timeout / shutdown_background) exposed via FFI, so an app can hard-stop the tokio runtime on background without an unbounded main-thread join.
    2. Guarding the reverse-P/Invoke callbacks to no-op when the runtime/handler is being torn down, rather than attaching a thread.

    Happy to share more crash instances or test a build. Thanks for the library!

  3. alvinsay commented on Sep 15, 2026

    @alvinsay

    We hit the same issue.

    Just made a PR. #171

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions