Search Unity

GC crash "Unexpected mark stack overflow"

Discussion in 'Scripting' started by tkumpumaki, Aug 24, 2021.

  1. tkumpumaki

    tkumpumaki

    Joined:
    Sep 26, 2018
    Posts:
    18
    We have been trying to find the source for GC crash. It seems to happen at least on OSX, Windows and Android.
    Our application creates quite a lot of threads for HttpWebrequests (which by itself seems to create lots of Tasks) and it will quite randomly within minutes or hours crash. Crash happens from random locations while GC is allocating some memory or from collect_incremental etc.

    Ironically on crash location, the GC_push_all source comments say that "Should only be used if there is no possibility of mark stack overflow." and well that precondition fails... Anyone got good ideas how to get rid of this problem? No bug report created yet as it's not sure if it is our fault.

    Editor version is 2020.3.8f1.

    On Android crash happens at: GC_mark_from, mark.c:851, stacktrace below.

    On OSX: GC_mark_from + 2058, stacktrace below.

    On Windows, it creates messagebox("Unexpected mark stack overflow") from :
    /*
    * Push all locations between b and t onto the mark stack.
    * b is the first location to be checked. t is one past the last
    * location to be checked.
    * Should only be used if there is no possibility of mark stack
    * overflow.
    */
    GC_API void GC_CALL GC_push_all(void *bottom, void *top)
    {
    word length;

    bottom = (void *)(((word)bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
    top = (void *)((word)top & ~(ALIGNMENT-1));
    if ((word)bottom >= (word)top) return;

    GC_mark_stack_top++;
    if ((word)GC_mark_stack_top >= (word)GC_mark_stack_limit) {
    ABORT("Unexpected mark stack overflow");
    }
    length = (word)top - (word)bottom;
    # if GC_DS_TAGS > ALIGNMENT - 1
    length += GC_DS_TAGS;
    length &= ~GC_DS_TAGS;
    # endif
    GC_mark_stack_top -> mse_start = (ptr_t)bottom;
    GC_mark_stack_top -> mse_descr.w = length;
    }

    Android Stacktrace:
    #00 pc 0000000004a90bb0 (GC_mark_from at C:\Program Files\Unity\Hub\Editor\2020.3.8f1\Editor\Data\il2cpp\external\bdwgc\extra/../mark.c:851) /data/app/~~jllIATuZnpfl8Qeqp-Tdnw==/com.DeltaCygniLabs.Pointr--VckFJ-JdGNnCykrYEc8Zw==/lib/arm64/libil2cpp.so (BuildId: 513cf18ee78d45c8ae454b335f5fe0a84d655bd3)
    #01 pc 0000000004a8d550 (GC_mark_some at :?) /data/app/~~jllIATuZnpfl8Qeqp-Tdnw==/com.DeltaCygniLabs.Pointr--VckFJ-JdGNnCykrYEc8Zw==/lib/arm64/libil2cpp.so (BuildId: 513cf18ee78d45c8ae454b335f5fe0a84d655bd3)
    #02 pc 0000000004a8d35c (GC_collect_a_little_inner at C:\Program Files\Unity\Hub\Editor\2020.3.8f1\Editor\Data\il2cpp\external\bdwgc\extra/../alloc.c:672) /data/app/~~jllIATuZnpfl8Qeqp-Tdnw==/com.DeltaCygniLabs.Pointr--VckFJ-JdGNnCykrYEc8Zw==/lib/arm64/libil2cpp.so (BuildId: 513cf18ee78d45c8ae454b335f5fe0a84d655bd3)
    #03 pc 0000000004a8edcc (GC_allocobj at C:\Program Files\Unity\Hub\Editor\2020.3.8f1\Editor\Data\il2cpp\external\bdwgc\extra/../alloc.c:1563) /data/app/~~jllIATuZnpfl8Qeqp-Tdnw==/com.DeltaCygniLabs.Pointr--VckFJ-JdGNnCykrYEc8Zw==/lib/arm64/libil2cpp.so (BuildId: 513cf18ee78d45c8ae454b335f5fe0a84d655bd3)
    #04 pc 0000000004a8a108 (GC_generic_malloc_inner at C:\Program Files\Unity\Hub\Editor\2020.3.8f1\Editor\Data\il2cpp\external\bdwgc\extra/../malloc.c:191) /data/app/~~jllIATuZnpfl8Qeqp-Tdnw==/com.DeltaCygniLabs.Pointr--VckFJ-JdGNnCykrYEc8Zw==/lib/arm64/libil2cpp.so (BuildId: 513cf18ee78d45c8ae454b335f5fe0a84d655bd3)
    #05 pc 0000000004a89ed0 (GC_gcj_malloc at :?) /data/app/~~jllIATuZnpfl8Qeqp-Tdnw==/com.DeltaCygniLabs.Pointr--VckFJ-JdGNnCykrYEc8Zw==/lib/arm64/libil2cpp.so (BuildId: 513cf18ee78d45c8ae454b335f5fe0a84d655bd3)
    #06 pc 0000000004a639b0 (il2cpp::vm::Object::AllocateSpec(unsigned long, Il2CppClass*) at C:\Program Files\Unity\Hub\Editor\2020.3.8f1\Editor\Data\il2cpp\libil2cpp\vm/Object.cpp:78) /data/app/~~jllIATuZnpfl8Qeqp-Tdnw==/com.DeltaCygniLabs.Pointr--VckFJ-JdGNnCykrYEc8Zw==/lib/arm64/libil2cpp.so (BuildId: 513cf18ee78d45c8ae454b335f5fe0a84d655bd3)

    OSX stacktrace:
    0 GameAssembly.dylib 0x00000001171676ba GC_mark_from + 2058
    1 GameAssembly.dylib 0x000000011715f5d2 GC_mark_some + 562
    2 GameAssembly.dylib 0x000000011715f213 GC_collect_a_little_inner + 115
    3 GameAssembly.dylib 0x0000000117161afe GC_allocobj + 174
    4 GameAssembly.dylib 0x0000000117158be6 GC_generic_malloc_inner + 486
    5 GameAssembly.dylib 0x00000001171586c0 GC_gcj_malloc + 224
    6 GameAssembly.dylib 0x00000001170a1abe il2cpp::vm::Object::AllocateSpec(unsigned long, Il2CppClass*) + 94
    7 GameAssembly.dylib 0x00000001170c7f45 il2cpp::vm::Object::NewAllocSpecific(Il2CppClass*) + 149
    8 GameAssembly.dylib 0x00000001170b3085 il2cpp::vm::Object::New(Il2CppClass*) + 21
    9 GameAssembly.dylib 0x00000001171c17f5 il2cpp_codegen_object_new(Il2CppClass*) + 21
     
  2. tkumpumaki

    tkumpumaki

    Joined:
    Sep 26, 2018
    Posts:
    18