Search Unity

Fatal Error in GC - Unexpected Mark Stack Overflow

Discussion in 'Editor & General Support' started by AshleyBates, Oct 3, 2019.

  1. AshleyBates

    AshleyBates

    Joined:
    Feb 24, 2017
    Posts:
    34
    Hello,

    We have a crash in our project that we can't find a solution to.

    The application loads mainly from a database, and is all UI based.

    The application can run for 5 seconds - half an hour and at some point we get a complete crash with the following error -

    GCError.png


    In the Unity error.log I get this -
    Stack Trace of Crashed Thread 11972:
    0x00007FF96EEBF412 (mono-2.0-bdwgc) GC_malloc_uncollectable
    ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF96EBB1BCC)
    0x00007FF96EBB1BCC (mono-2.0-bdwgc) (function-name not available)

    which I have read basically means Unity does not know what the real error is.

    I then opened up the crash dump file, analyzed it and got the following stack text -

    STACK_TEXT:
    000000b0`3e2fdaf0 00007ff9`6ebb1bcc : 0000029e`25985760 00000000`00000000 00000000`00000000 00000000`00000000 : mono_2_0_bdwgc!GC_push_all+0x46
    000000b0`3e2fdb20 00007ff9`6ecc758f : 00000000`00000007 00000000`00000007 00000000`00000000 00000000`00000001 : mono_2_0_bdwgc!monoeg_g_hash_table_foreach+0x9c
    000000b0`3e2fdb70 00007ff9`6eebfff5 : 00000000`00000006 000000b0`3e2fdcb0 00000000`00000001 00000000`00000000 : mono_2_0_bdwgc!mono_push_other_roots+0x1f
    000000b0`3e2fdba0 00007ff9`6eebd875 : 00000000`00000024 00000000`00000001 00000000`00000000 00000000`00000000 : mono_2_0_bdwgc!GC_push_roots+0xc9
    000000b0`3e2fdbd0 00007ff9`6eebd655 : 00000000`00000024 00000000`00000000 00000000`00000000 00000000`00000000 : mono_2_0_bdwgc!GC_mark_some_inner+0x1c9
    000000b0`3e2fdc00 00007ff9`6eec2b66 : 00007ff9`6eeb41b8 00000000`00000000 00007ff9`6eeb41b8 00000000`00000000 : mono_2_0_bdwgc!GC_mark_some+0x9
    000000b0`3e2fdc40 00007ff9`6eec3397 : 000000b0`3e2fdcb0 00000000`00000000 00000000`00000000 00000000`00000001 : mono_2_0_bdwgc!GC_stopped_mark+0x112
    000000b0`3e2fdcb0 00007ff9`6eeb68c3 : 00000000`00000000 00000000`00000006 00007ff9`6f04d7e8 00000000`00000001 : mono_2_0_bdwgc!GC_try_to_collect_inner+0x15b
    000000b0`3e2fdcf0 00007ff9`6eeb564c : 00000000`00000006 00000000`00000000 00000000`00000001 00007ff7`caae4d90 : mono_2_0_bdwgc!GC_collect_or_expand+0xb3
    000000b0`3e2fdd20 00007ff9`6eeba168 : 00000000`00000001 00000000`00000001 00000000`00000050 00000000`00000006 : mono_2_0_bdwgc!GC_allocobj+0xcc
    000000b0`3e2fdd60 00007ff9`6eeb9e3f : 00000000`00000000 00000000`00000001 00000000`00000050 0000029d`b7f0e4b0 : mono_2_0_bdwgc!GC_generic_malloc_inner+0x124
    000000b0`3e2fdda0 00007ff9`6eebcc84 : 00000000`00000000 00000000`00000000 00000000`00000001 00000000`00000001 : mono_2_0_bdwgc!GC_generic_malloc+0x16b
    000000b0`3e2fdde0 00007ff9`6ecc5dbe : 00000000`00000000 00000000`00000050 0000029d`b7f033f0 0000029d`00000018 : mono_2_0_bdwgc!GC_malloc_kind_global+0xd8
    000000b0`3e2fde10 00007ff9`6ec691c5 : 00000000`00000000 000000b0`3e2fdee0 0000029d`b7f0cb40 00000000`00000001 : mono_2_0_bdwgc!mono_gc_alloc_obj+0x7e
    000000b0`3e2fde40 00007ff9`6ec696fa : 00000000`00000000 0000029d`0dfcf0e0 0000029d`5feae540 0000029d`1ae51a20 : mono_2_0_bdwgc!mono_object_new_alloc_specific_checked+0x25
    000000b0`3e2fde70 00007ff9`6ec6eaf3 : 0000029d`b7f036c0 00000000`00000000 000000b0`3e2fdfe0 00000000`00000000 : mono_2_0_bdwgc!mono_object_new_specific_checked+0x1ba
    000000b0`3e2fdec0 0000029d`60dc17e8 : 0000029d`b7f03301 0000029d`3e518950 00000000`00000000 0000029d`b7f033f0 : mono_2_0_bdwgc!ves_icall_object_new_specific+0x13
    000000b0`3e2fdf60 0000029d`1b5cc863 : 00000000`00000000 0000029d`b7f0cb40 00007ff9`6f049d98 00000000`00000000 : 0x0000029d`60dc17e8
    000000b0`3e2fdff0 0000029d`1ca1978b : 00000000`00000000 0000029d`b7f036c0 00000000`00000000 00000000`00000000 : 0x0000029d`1b5cc863
    000000b0`3e2fe050 0000029d`1ca09bd3 : 00000000`00000000 00000000`00000000 0000029d`53db27c0 00007ff7`c625efa1 : 0x0000029d`1ca1978b
    000000b0`3e2fe0b0 0000029d`1ca035d3 : 00000000`00000000 0000029d`b7f0b8a0 ffffffff`fffffffe 0000029d`53db2840 : 0x0000029d`1ca09bd3
    000000b0`3e2fe3a0 0000029d`1c9fe7eb : 0000029d`6fd40f60 00000000`00000000 0000029d`b7f08b80 0000029d`1ca0181b : 0x0000029d`1ca035d3
    000000b0`3e2fe4b0 0000029d`1c9fcad3 : 0000029d`6fd40f60 00000000`00000000 0000029d`0e670238 0000029d`0e670238 : 0x0000029d`1c9fe7eb
    000000b0`3e2fe6f0 0000029d`1ca3731b : 00000000`00000000 00000000`00000000 00000000`7fffffff 0000029d`b7e801e0 : 0x0000029d`1c9fcad3
    000000b0`3e2fe7a0 0000029d`1ca36dab : 0000029d`198f5880 00000000`00000000 0000029d`52122270 000000b0`3e2fe980 : 0x0000029d`1ca3731b
    000000b0`3e2fe8b0 0000029d`1b5cb943 : 0000029d`198f5880 0000029d`b7e982a0 00000000`00000000 00000000`00000000 : 0x0000029d`1ca36dab
    000000b0`3e2fe990 0000029d`1b5cb5b3 : 00000000`00000000 0000029d`6fd40f60 00000000`00000001 0000029d`30d39d10 : 0x0000029d`1b5cb943
    000000b0`3e2fea20 0000029d`1b5cada3 : 00000000`00000000 0000029d`6fd40f60 000000b0`3e2ff8a0 000000b0`3e2feb30 : 0x0000029d`1b5cb5b3
    000000b0`3e2feac0 0000029d`2750edab : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : 0x0000029d`1b5cada3
    000000b0`3e2feb40 0000029d`27908003 : 00000000`00000000 00000000`00000000 00000010`c143808e 0000029d`53db27c0 : 0x0000029d`2750edab
    000000b0`3e2fec30 0000029d`278f2b13 : 00000000`00000000 00000000`00000000 00022074`00769000 00000000`00000000 : 0x0000029d`27908003
    000000b0`3e2fed70 0000029d`27904d0a : 00000000`00000000 00000000`00000001 00000000`00000001 00000000`00000001 : 0x0000029d`278f2b13
    000000b0`3e2ff040 0000029d`273f2551 : 00000000`00000000 00000000`00000001 00000010`c13e038e 0000029d`53db27c0 : 0x0000029d`27904d0a
    000000b0`3e2ff0a0 0000029d`273f1c5b : 00000000`00000000 0000029d`1975dc00 0000029d`491b5a18 0000029d`491b5a18 : 0x0000029d`273f2551
    000000b0`3e2ff180 0000029d`279049b3 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : 0x0000029d`273f1c5b
    000000b0`3e2ff1e0 0000029d`27902e52 : 00000000`00000000 0000029d`b7df6d70 0000029d`5feae540 00000000`00000000 : 0x0000029d`279049b3
    000000b0`3e2ff260 0000029d`279012e3 : 00000000`00000000 0000029d`b7df6d70 00000000`00000001 0000029d`53db27c0 : 0x0000029d`27902e52
    000000b0`3e2ff300 0000029d`279001a3 : 000000b0`3e2ffd20 0000029d`b7df6d70 0000029d`b7df6d70 00000000`00000000 : 0x0000029d`279012e3
    000000b0`3e2ff4a0 0000029d`278fe623 : 000000b0`3e2ffd20 0000029d`b7df6d70 0000029d`52122270 000000b0`3e2ff600 : 0x0000029d`279001a3
    000000b0`3e2ff4f0 0000029d`278fd9a3 : 000000b0`3e2ffd20 0000029d`b7df6d70 0000029d`491b4fb0 0000029d`491b4fb0 : 0x0000029d`278fe623
    000000b0`3e2ff560 0000029d`278f9823 : 000000b0`3e2ffd20 0000029d`b7df6d70 00000000`00000000 00007ff9`6ec78419 : 0x0000029d`278fd9a3
    000000b0`3e2ff610 0000029d`278f822b : 000000b0`3e2ffd20 00000000`006dcd02 0000029d`184f8be8 0000029d`184f8be8 : 0x0000029d`278f9823
    000000b0`3e2ff6b0 0000029d`278f7b0b : 000000b0`3e2ffd20 00000000`006dcd02 000000b0`3e2ff860 0000029d`274826c3 : 0x0000029d`278f822b
    000000b0`3e2ff710 0000029d`27482a81 : 000000b0`3e2ffd20 00000000`00000000 0000029d`53db27c0 0000029d`52122270 : 0x0000029d`278f7b0b
    000000b0`3e2ff760 0000029d`274821eb : 000000b0`3e2ffd20 0000029d`48c99a00 000000b0`3e2ffd20 0000029d`18506830 : 0x0000029d`27482a81
    000000b0`3e2ff870 0000029d`1b5e7be5 : 000000b0`3e2ffd20 0000029d`27482100 00000000`00000000 00000000`00000000 : 0x0000029d`274821eb
    000000b0`3e2ff910 00007ff9`6ecdc010 : ffffffff`fba98db7 000000b0`3e2ffc60 000000b0`00000000 0000029d`6da000b8 : 0x0000029d`1b5e7be5
    000000b0`3e2ff9d0 00007ff9`6ec62122 : 0000029d`b8be3bd0 00007ff9`6ec6b65a 00007ff9`6ec8b410 00007ff9`6ebcf460 : mono_2_0_bdwgc!mono_jit_runtime_invoke+0x530
    000000b0`3e2ffbb0 00007ff9`6ec88f31 : 0000029d`0dc08070 000000b0`3e2ffca9 00007ff9`6ec8b410 00007ff9`6ec8b410 : mono_2_0_bdwgc!do_runtime_invoke+0x82
    000000b0`3e2ffc00 00007ff9`6ec8b5b1 : 0000029d`00020000 00007ff9`00010001 00000000`00000000 00000000`00002ec4 : mono_2_0_bdwgc!worker_callback+0x411
    000000b0`3e2ffd10 00007ff9`6ec85b68 : 0000029d`5d562e60 00010003`00000018 00007ff9`6ec8b410 0000029d`6fd32d20 : mono_2_0_bdwgc!worker_thread+0x1a1
    000000b0`3e2ffd40 00007ff9`6ec858f6 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : mono_2_0_bdwgc!start_wrapper_internal+0x248
    000000b0`3e2ffe10 00007ff9`c3e37bd4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : mono_2_0_bdwgc!start_wrapper+0x46
    000000b0`3e2ffe40 00007ff9`c46ecee1 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : kernel32!BaseThreadInitThunk+0x14
    000000b0`3e2ffe70 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21


    FAULTING_SOURCE_LINE: c:\build\output\unity-technologies\mono\external\bdwgc\mark.c

    FAULTING_SOURCE_FILE: c:\build\output\unity-technologies\mono\external\bdwgc\mark.c

    FAULTING_SOURCE_LINE_NUMBER: 1351

    FAULTING_SOURCE_CODE:
    No source found for 'c:\build\output\unity-technologies\mono\external\bdwgc\mark.c'


    Can anyone shed any light on what this is, or how we can narrow down the problem. It appears as though it is a lost reference in memory to an object, but we don't even destroy objects in the application anymore, we re-use them (in an attempt to fix this problem). The issue we have now is that I can't pinpoint the location in he code that is causing the problem, if maybe I understood it a bit more we may have more of a chance.

    I hope someone can help as it is a real stand still moment in the project.

    Thank You.
     
  2. moggesmith10

    moggesmith10

    Joined:
    Jan 11, 2018
    Posts:
    1
    Had this problem myself, though it was just me starting threads in Update rather than Start by mistake. See if that might be the problem.
     
  3. joeheacom

    joeheacom

    Joined:
    Mar 31, 2017
    Posts:
    1
    This just started happening to me. Did you figure it out?
     
  4. AshleyBates

    AshleyBates

    Joined:
    Feb 24, 2017
    Posts:
    34
    Yes, but no. Originally we switched from mono to IL2CPP, and this made the error go away, but we made lots of code changes to the project / re-wrote some systems, and then a couple of months later did a build back under mono, and this error went away. So we fixed it, but I unfortunately really have no idea what the cause was.
     
  5. krzysztofchwiolka

    krzysztofchwiolka

    Joined:
    May 20, 2021
    Posts:
    1
    If anyone ever comes and deals with this.

    You may have something being created that is not being disposed of properly even after it has been used or the thread it has been on has finished work.

    try the 'using' statement on such a function, as it will automatically be disposed once not in use (Some IDEs may even mark this).

    as an example:
    Code (CSharp):
    1. using (System.Net.WebClient webClient = new System.Net.WebClient())
    2. {
    3. Code that is using the variable
    4. }
    instead of
    Code (CSharp):
    1. System.Net.WebClient webClient = new System.Net.WebClient()
    2. Code that is using the variable
     
    Last edited: Dec 21, 2021
    avataris-io likes this.
  6. avataris-io

    avataris-io

    Joined:
    Jun 23, 2020
    Posts:
    37
    Hey! We was getting the same error, what was helping is to regenerate nodes for project.
     
  7. Grafos

    Grafos

    Joined:
    Aug 30, 2011
    Posts:
    231
    Been getting the same problem the past few days. Whenever I try to enter play mode, and sometimes even randomly while I perform stuff in the editor. Sometimes the message appears immediately, and other times unity freezes and memory usage of the editor slowly builds to 20+ GB until it eventually crashes. I have no clue how it started and why it's happening. Can anyone help?