IL2CPP player crashes when a managed debugger is attached with following stacktrace (on windows):
[Inline Frame] UnityPlayer.dll!MemoryManager::VirtualAllocator::GetMemoryBlockOwnerAndOffset(int) Line 660 C++
UnityPlayer.dll!MemoryManager::VirtualAllocator::GetBlockInfoFromPointer(const void * ptr) Line 785 C++
UnityPlayer.dll!DualThreadAllocator<DynamicHeapAllocator>::Contains(const void * p) Line 305 C++
UnityPlayer.dll!MemoryManager::Deallocate(void * ptr, const MemLabelId & label, const char * file, int line) Line 2094 C++
UnityPlayer.dll!free_alloc_internal(void * ptr, const MemLabelId & label, const char * file, int line) Line 458 C++
UnityPlayer.dll!Il2cppMemoryWrapper::Deallocate(void * memory) Line 124 C++
> GameAssembly.dll!vm_commands(int command, int id, unsigned char * p, unsigned char * end, Buffer * buf) Line 7922 C
GameAssembly.dll!debugger_thread(void * arg) Line 11349 C
GameAssembly.dll!il2cpp::os::Thread::RunWrapper(void * arg) Line 202 C++
GameAssembly.dll!il2cpp::os::ThreadStartWrapper(void * arg) Line 28 C++
kernel32.dll!00007ff9e0837034() Unknown
ntdll.dll!00007ff9e0b02651() Unknown
This is caused by recent changes to memory overrides in Unity.
In il2cpp memory is sometimes allocated using functions that call malloc() internally and freed using mono g_free() which work because without overrides they both call into libc malloc and free. When using an override in Unity g_free uses a custom memory manager.