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

Il2cpp crashing... #540

Closed
kamyker opened this issue Jul 20, 2021 · 7 comments
Closed

Il2cpp crashing... #540

kamyker opened this issue Jul 20, 2021 · 7 comments

Comments

@kamyker
Copy link
Contributor

kamyker commented Jul 20, 2021

I'm not sure what happens but game built with il2cpp crashes overtime when Unity tries to allocate something big like float[]. Are all pointers allocated correctly? I think it crashes when Unity tried to use the same memory that's used by ilruntime.

The end of stacktrace is always:

Stack Trace of Crashed Thread 87940:
0x00007FF9BB87C36A (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\libil2cpp\os\Win32\Assert.cpp:12] il2cpp_assert 
0x00007FF9BB9E4306 (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\libil2cpp\gc\BoehmGC.cpp:67] GC_gcj_vector_proc 
0x00007FF9BB995B07 (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\external\bdwgc\mark.c:782] GC_mark_from 
0x00007FF9BB9966D3 (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\external\bdwgc\mark.c:361] GC_mark_some_inner 
0x00007FF9BB9964FA (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\external\bdwgc\mark.c:506] GC_mark_some 
0x00007FF9BB99F037 (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\external\bdwgc\alloc.c:832] GC_stopped_mark 
0x00007FF9BB99FB6B (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\external\bdwgc\alloc.c:580] GC_try_to_collect_inner 
0x00007FF9BB98A601 (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\external\bdwgc\alloc.c:1484] GC_collect_or_expand 
0x00007FF9BB9884DE (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\external\bdwgc\alloc.c:1579] GC_allocobj 
0x00007FF9BB99022D (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\external\bdwgc\malloc.c:191] GC_generic_malloc_inner 
0x00007FF9BB98FC3F (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\external\bdwgc\malloc.c:251] GC_generic_malloc 
0x00007FF9BB994B8D (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\external\bdwgc\malloc.c:327] GC_malloc_kind_global 
0x00007FF9BB994A3C (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\external\bdwgc\malloc.c:334] GC_malloc_kind 
0x00007FF9BB9946C6 (GameAssembly) [C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\external\bdwgc\malloc.c:342] GC_malloc_atomic 
@liiir1985
Copy link
Collaborator

liiir1985 commented Jul 20, 2021

ILRuntime is purely implemented in c#, so basically it has no difference between it and your game code written in Unity, all memories allocated by ilruntime is using the common way which people would do with ordinary c# code with only 1 exception, the evaluation stack( inside RuntimeStack class, but it has nothing to do with boehm gc, it won't touch such memory). This crash may be engine version related, have you tried with another unity version? The known pattern of random crash with il2cpp is if you build the game with debug profile for c++/ xcode, the game would crash when the call stack gets deep due to stack overflow.

@liiir1985
Copy link
Collaborator

Besides, since the source code of il2cpp is avaliable, so you can try debug your game with visual studio, when it crashes, it'll stop at BoehmGC.cpp:67, so you can check out why it failed to read the class's value type

@kamyker
Copy link
Contributor Author

kamyker commented Jul 20, 2021

Crash at something like: var arr = new float[bignumber]; then:

 	GameAssembly.dll!il2cpp_assert(const char * assertion, const char * file, unsigned int line) Line 12	C++
>	GameAssembly.dll!GC_gcj_vector_proc(unsigned __int64 * addr, GC_ms_entry * mark_stack_ptr, GC_ms_entry * mark_stack_limit, unsigned __int64 env) Line 67	C++
 	GameAssembly.dll!GC_mark_from(GC_ms_entry * mark_stack_top, GC_ms_entry * mark_stack, GC_ms_entry * mark_stack_limit) Line 782	C
 	GameAssembly.dll!GC_mark_some_inner(char * cold_gc_frame) Line 361	C
 	GameAssembly.dll!GC_mark_some(char * cold_gc_frame) Line 506	C
 	GameAssembly.dll!GC_stopped_mark(int(*)() stop_func) Line 832	C
 	GameAssembly.dll!GC_try_to_collect_inner(int(*)() stop_func) Line 580	C
 	GameAssembly.dll!GC_collect_or_expand(unsigned __int64 needed_blocks, int ignore_off_page, int retry) Line 1484	C
 	GameAssembly.dll!GC_alloc_large(unsigned __int64 lb, int k, unsigned int flags) Line 64	C
 	GameAssembly.dll!GC_generic_malloc(unsigned __int64 lb, int k) Line 264	C
 	GameAssembly.dll!GC_malloc_kind_global(unsigned __int64 lb, int k) Line 327	C
 	GameAssembly.dll!GC_malloc_kind(unsigned __int64 lb, int k) Line 334	C
 	GameAssembly.dll!GC_malloc_atomic(unsigned __int64 lb) Line 342	C
 	GameAssembly.dll!il2cpp::vm::Object::AllocatePtrFree(unsigned __int64 size, Il2CppClass * typeInfo) Line 67	C++
 	GameAssembly.dll!il2cpp::vm::Array::NewSpecific(Il2CppClass * klass, unsigned __int64 n) Line 128	C++
 	GameAssembly.dll!SZArrayNew(Il2CppClass * arrayType, unsigned int length) Line 121	C++

image

  Name Value Type
element_type 0x0000018dd9b08310 {image=0x0000018cf9031be8 {name=0x0000018cf96195cc "System.Collections.Immutable.dll" ...} ...} Il2CppClass *
  ▶ image 0x0000018cf9031be8 {name=0x0000018cf96195cc "System.Collections.Immutable.dll" nameNoExt=0x0000018cf9034cb0 "System.Collections.Immutable" ...} const Il2CppImage *
  gc_desc 0x0000000000000008 void *
  ▶ name 0x0000018cf9619ea6 "ImmutableArray`1" const char *
  ▶ namespaze 0x0000018cf961950b "System.Collections.Immutable" const char *
  ▶ byval_arg {data={dummy=0x00007fffbc1a1380 {GameAssembly.dll!Il2CppGenericClass ImmutableArray_1_tC4DBABD9A1FC859F88C2E53876452E133A0845C1_GenericClass} ...} ...} Il2CppType
  ▶ this_arg {data={dummy=0x00007fffbc1a1380 {GameAssembly.dll!Il2CppGenericClass ImmutableArray_1_tC4DBABD9A1FC859F88C2E53876452E133A0845C1_GenericClass} ...} ...} Il2CppType
  ▶ element_class 0x0000018dd9b08310 {image=0x0000018cf9031be8 {name=0x0000018cf96195cc "System.Collections.Immutable.dll" ...} ...} Il2CppClass *
  ▶ castClass 0x0000018dd9b08310 {image=0x0000018cf9031be8 {name=0x0000018cf96195cc "System.Collections.Immutable.dll" ...} ...} Il2CppClass *
  ▶ declaringType 0x0000000000000000 Il2CppClass *
  ▶ parent 0x0000018cf9205c90 {image=0x0000018cf9030eb0 {name=0x0000018cf954d0c5 "mscorlib.dll" nameNoExt=0x0000018cf8fa0470 "mscorlib" ...} ...} Il2CppClass *
  ▶ generic_class 0x00007fffbc1a1380 {GameAssembly.dll!Il2CppGenericClass ImmutableArray_1_tC4DBABD9A1FC859F88C2E53876452E133A0845C1_GenericClass} {...} Il2CppGenericClass *
  typeMetadataHandle 0x0000000000000000 const ___Il2CppMetadataTypeHandle *
  ▶ interopData 0x0000000000000000 const Il2CppInteropData *
  ▶ klass 0x0000018dd9b08310 {image=0x0000018cf9031be8 {name=0x0000018cf96195cc "System.Collections.Immutable.dll" ...} ...} Il2CppClass *
  ▶ fields 0x0000018dd9b0ab30 {name=0x0000018cf9551ae2 "Empty" type=0x0000018dd9b0ab70 {data={dummy=0x00007fffbc1a1380 {GameAssembly.dll!Il2CppGenericClass ImmutableArray_1_tC4DBABD9A1FC859F88C2E53876452E133A0845C1_GenericClass} ...} ...} ...} FieldInfo *
  ▶ events 0x0000000000000000 const EventInfo *
  ▶ properties 0x0000018dd9b116d8 {parent=0x0000018dd9b08310 {image=0x0000018cf9031be8 {name=0x0000018cf96195cc "System.Collections.Immutable.dll" ...} ...} ...} const PropertyInfo *
  ▶ methods 0x0000018dd9b0b500 {0x0000018dd9b0b720 {methodPointer=0x00007fffae240ac0 {GameAssembly.dll!ImmutableArray_1_System_Collections_Generic_IListU3CTU3E_get_Item_m2446982ED9E06819F65568242EEB91F5ED09D9FD_AdjustorThunk(Il2CppObject *, int, const MethodInfo *)} ...}} const MethodInfo * *
  ▶ nestedTypes 0x0000000000000000 {???} Il2CppClass * *
  ▶ implementedInterfaces 0x0000018dd9b0ab90 {0x0000018dd9b0ac08 {image=0x0000018cf9030eb0 {name=0x0000018cf954d0c5 "mscorlib.dll" ...} ...}} Il2CppClass * *
  ▶ interfaceOffsets 0x0000018dd9b11588 {interfaceType=0x0000018dd9b0ac08 {image=0x0000018cf9030eb0 {name=0x0000018cf954d0c5 "mscorlib.dll" ...} ...} ...} Il2CppRuntimeInterfaceOffsetPair *
  static_fields 0x0000018dd9553740 void *
  ▶ rgctx_data 0x0000018dd9b11980 {rgctxDataDummy=0x0000018dd9b114d0 method=0x0000018dd9b114d0 {methodPointer=0x00007fffae247b40 {GameAssembly.dll!ImmutableArray_1_ThrowInvalidOperationIfNotInitialized_mB210BDB576FC9F46AC8DE88100B19F274D472D4E_AdjustorThunk(Il2CppObject *, const MethodInfo *)} ...} ...} const Il2CppRGCTXData *
  ▶ typeHierarchy 0x0000018dd9b11570 {0x0000018cf9205910 {image=0x0000018cf9030eb0 {name=0x0000018cf954d0c5 "mscorlib.dll" ...} ...}} Il2CppClass * *
  unity_user_data 0x0000000000000000 void *
  initializationExceptionGCHandle 0 unsigned int
  cctor_started 0 unsigned int
  cctor_finished 0 unsigned int
  cctor_thread 0 unsigned __int64
  genericContainerHandle 0x0000000000000000 const ___Il2CppMetadataGenericContainerHandle *
  instance_size 24 unsigned int
  actualSize 24 unsigned int
  element_size 0 unsigned int
  native_size -1 int
  static_fields_size 8 unsigned int
  thread_static_fields_size 0 unsigned int
  thread_static_fields_offset -1 int
  flags 1048841 unsigned int
  token 33554465 unsigned int
  method_count 68 unsigned short
  property_count 17 unsigned short
  field_count 2 unsigned short
  event_count 0 unsigned short
  nested_type_count 0 unsigned short
  vtable_count 41 unsigned short
  interfaces_count 13 unsigned short
  interface_offsets_count 13 unsigned short
  typeHierarchyDepth 3 '\x3' unsigned char
  genericRecursionDepth 1 '\x1' unsigned char
  rank 0 '\0' unsigned char
  minimumAlignment 8 '\b' unsigned char
  naturalAligment 8 '\b' unsigned char
  packingSize 0 '\0' unsigned char
  initialized_and_no_error 1 '\x1' unsigned char
  valuetype 1 '\x1' unsigned char
  initialized 1 '\x1' unsigned char
  enumtype 0 '\0' unsigned char
  is_generic 0 '\0' unsigned char
  has_references 1 '\x1' unsigned char
  init_pending 0 '\0' unsigned char
  size_inited 1 '\x1' unsigned char
  has_finalize 0 '\0' unsigned char
  has_cctor 1 '\x1' unsigned char
  is_blittable 0 '\0' unsigned char
  is_import_or_windows_runtime 0 '\0' unsigned char
  is_vtable_initialized 1 '\x1' unsigned char
  has_initialization_error 0 '\0' unsigned char
  vtable 0x0000018dd9b08448 {...} VirtualInvokeData[0]

@kamyker
Copy link
Contributor Author

kamyker commented Jul 20, 2021

Good news: https://forum.unity.com/threads/il2cpp-crash-at-malloc.1144004/#post-7344806

@liiir1985
Copy link
Collaborator

nice to hear that Unity already addressed the issue.
Any news about this?

@kamyker
Copy link
Contributor Author

kamyker commented Aug 12, 2021

It was supposed to get fixed in 2020.3.16 but it still crashes.

@kamyker
Copy link
Contributor Author

kamyker commented Aug 13, 2021

Seems like it was caused by another plugin that probably corrupted memory later on used by ilruntime.

@kamyker kamyker closed this as completed Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants