Skip to content

Crash on reentry of tiered compilation #107074

Open
@angelowang

Description

@angelowang

Description

When our product (Autodesk Civil 3D) turns on tiered compilation and open some specific file, it will crash when the JIT is triggered in a reentry way. Let me try to describe it clearly.

  • There are two managed DLLs involved, AeccDbMgd.dll and AecBaseMgd.dll. AeccDbMgd.dll uses AecBaseMgd.dll.
  • The process will not load AecBaseMgd on start up, but on demand.
  • During start up, some native 'observer' code will try to construct a .NET object wrapper in AeccDbMgd.dll, which triggers the first JIT.
  • Due to the dependency between the two dlls, AecBaseMgd.dll will be loaded.
  • AutoCAD has some code that fires some events during loading of AecBaseMgd.dll, eventually triggers similar 'observer' code as above, and then the second time JIT.

Callstack is something like below:

Exception thrown at 0x00007FF88B0BB699 in acad.exe: Microsoft C++ exception: EETypeLoadException at memory location 0x00000070FDFEA860.
Some lines are omitted/obfuscated for confidentiality.

 	KernelBase.dll!00007ff88b0bb699()	Unknown
 	clrjit.dll!Compiler::impImportBlockCode(BasicBlock * block=0x000001d48ac788a0) Line 8397	C++
 	clrjit.dll!Compiler::impImportBlock(BasicBlock * block=0x000001d48ac788a0) Line 11237	C++
 	clrjit.dll!Compiler::impImport() Line 12187	C++
 	clrjit.dll!Compiler::fgImport() Line 580	C++
 	[Inline Frame] clrjit.dll!Phase::Run() Line 61	C++
 	[Inline Frame] clrjit.dll!DoPhase(Compiler *) Line 136	C++
 	clrjit.dll!Compiler::compCompile(void * * methodCodePtr=0x00000070fdfeeda0, unsigned int * methodCodeSize=0x00000070fdfeee58, JitFlags * compileFlags=0x00000070fdfeedc0) Line 4542	C++
 	clrjit.dll!Compiler::compCompileHelper(CORINFO_MODULE_STRUCT_ * classPtr, ICorJitInfo * compHnd=0x00000070fdfef1d0, CORINFO_METHOD_INFO * methodInfo=0x00000070fdfef0c0, void * * methodCodePtr=0x00000070fdfeeda0, unsigned int * methodCodeSize=0x00000070fdfeee58, JitFlags * compileFlags=0x00000070fdfeedc0) Line 7150	C++
 	clrjit.dll!Compiler::compCompile(CORINFO_MODULE_STRUCT_ * classPtr=0x00007fff45054c98, void * * methodCodePtr=0x00000070fdfeeda0, unsigned int * methodCodeSize=0x00000070fdfeee58, JitFlags * compileFlags=0x00000070fdfeedc0) Line 6292	C++
 	clrjit.dll!jitNativeCode(CORINFO_METHOD_STRUCT_ * methodHnd=0x00007fff45131a08, CORINFO_MODULE_STRUCT_ * classPtr=0x00007fff45054c98, ICorJitInfo * compHnd=0x00000070fdfef1d0, CORINFO_METHOD_INFO * methodInfo=0x00000070fdfef0c0, void * * methodCodePtr=0x00000070fdfeeda0, unsigned int * methodCodeSize=0x00000070fdfeee58, JitFlags * compileFlags=0x00000070fdfeedc0, void * inlineInfoPtr) Line 7783	C++
 	clrjit.dll!CILJit::compileMethod(ICorJitInfo * compHnd=0x00000070fdfef1d0, CORINFO_METHOD_INFO * methodInfo=0x00000070fdfef0c0, unsigned int flags=2147483652, unsigned char * * entryAddress=0x00000070fdfeee68, unsigned int * nativeSizeOfCode=0x00000070fdfeee58) Line 299	C++
 	[Managed to Native Transition]	
 	[Native to Managed Transition]	
 	KernelBase.dll!00007ff88b0bb699()	Unknown
 	clrjit.dll!Compiler::impImportBlockCode(BasicBlock * block=0x000001d48ac788a0) Line 8397	C++
 	clrjit.dll!Compiler::impImportBlock(BasicBlock * block=0x000001d48ac788a0) Line 11237	C++
 	clrjit.dll!Compiler::impImport() Line 12187	C++
 	clrjit.dll!Compiler::fgImport() Line 580	C++
 	[Inline Frame] clrjit.dll!Phase::Run() Line 61	C++
 	[Inline Frame] clrjit.dll!DoPhase(Compiler *) Line 136	C++
 	clrjit.dll!Compiler::compCompile(void * * methodCodePtr=0x00000070fdfeeda0, unsigned int * methodCodeSize=0x00000070fdfeee58, JitFlags * compileFlags=0x00000070fdfeedc0) Line 4542	C++
 	clrjit.dll!Compiler::compCompileHelper(CORINFO_MODULE_STRUCT_ * classPtr, ICorJitInfo * compHnd=0x00000070fdfef1d0, CORINFO_METHOD_INFO * methodInfo=0x00000070fdfef0c0, void * * methodCodePtr=0x00000070fdfeeda0, unsigned int * methodCodeSize=0x00000070fdfeee58, JitFlags * compileFlags=0x00000070fdfeedc0) Line 7150	C++
 	clrjit.dll!Compiler::compCompile(CORINFO_MODULE_STRUCT_ * classPtr=0x00007fff45054c98, void * * methodCodePtr=0x00000070fdfeeda0, unsigned int * methodCodeSize=0x00000070fdfeee58, JitFlags * compileFlags=0x00000070fdfeedc0) Line 6292	C++
 	clrjit.dll!jitNativeCode(CORINFO_METHOD_STRUCT_ * methodHnd=0x00007fff45131a08, CORINFO_MODULE_STRUCT_ * classPtr=0x00007fff45054c98, ICorJitInfo * compHnd=0x00000070fdfef1d0, CORINFO_METHOD_INFO * methodInfo=0x00000070fdfef0c0, void * * methodCodePtr=0x00000070fdfeeda0, unsigned int * methodCodeSize=0x00000070fdfeee58, JitFlags * compileFlags=0x00000070fdfeedc0, void * inlineInfoPtr) Line 7783	C++
 	clrjit.dll!CILJit::compileMethod(ICorJitInfo * compHnd=0x00000070fdfef1d0, CORINFO_METHOD_INFO * methodInfo=0x00000070fdfef0c0, unsigned int flags=2147483652, unsigned char * * entryAddress=0x00000070fdfeee68, unsigned int * nativeSizeOfCode=0x00000070fdfeee58) Line 299	C++
 	[Managed to Native Transition]	
 	acdbmgd.dll!<<<<<< Create .NET wrapper object 2 via C++/CLI >>>>>>
 	[Native to Managed Transition]	
 	acdb25.dll!<<<<<< Reactors fired on object 2 modification >>>>>>
        acdb25.dll!<<<<<< Object 2 is modified >>>>>>
 	acdb25.dll!<<<<<< Load AecBaseMgd.dll during JIT 1st time >>>>>>
 	[Managed to Native Transition]	
 	System.Private.CoreLib.dll!System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(string assemblyPath) Line 347	C#
 	System.Private.CoreLib.dll!System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(System.Reflection.AssemblyName assemblyName = {System.Reflection.AssemblyName}) Line 632	C#
 	System.Private.CoreLib.dll!System.Runtime.Loader.AssemblyLoadContext.ResolveUsingEvent(System.Reflection.AssemblyName assemblyName) Line 698	C#
 	System.Private.CoreLib.dll!System.Runtime.Loader.AssemblyLoadContext.ResolveUsingResolvingEvent(nint gchManagedAssemblyLoadContext, System.Reflection.AssemblyName assemblyName) Line 134	C#
 	[Native to Managed Transition]	
 	clrjit.dll!Compiler::impImportBlockCode(BasicBlock * block=0x000001d495cf2a90) Line 8397	C++
 	clrjit.dll!Compiler::impImportBlock(BasicBlock * block=0x000001d495cf2a90) Line 11237	C++
 	clrjit.dll!Compiler::impImport() Line 12187	C++
 	clrjit.dll!Compiler::fgImport() Line 580	C++
 	[Inline Frame] clrjit.dll!Phase::Run() Line 61	C++
 	[Inline Frame] clrjit.dll!DoPhase(Compiler *) Line 136	C++
 	clrjit.dll!Compiler::compCompile(void * * methodCodePtr=0x00000070fdffc3b0, unsigned int * methodCodeSize=0x00000070fdffc468, JitFlags * compileFlags=0x00000070fdffc3d0) Line 4542	C++
 	clrjit.dll!Compiler::compCompileHelper(CORINFO_MODULE_STRUCT_ * classPtr, ICorJitInfo * compHnd=0x00000070fdffc7e0, CORINFO_METHOD_INFO * methodInfo=0x00000070fdffc6d0, void * * methodCodePtr=0x00000070fdffc3b0, unsigned int * methodCodeSize=0x00000070fdffc468, JitFlags * compileFlags=0x00000070fdffc3d0) Line 7150	C++
 	clrjit.dll!Compiler::compCompile(CORINFO_MODULE_STRUCT_ * classPtr=0x00007fff45054c98, void * * methodCodePtr=0x00000070fdffc3b0, unsigned int * methodCodeSize=0x00000070fdffc468, JitFlags * compileFlags=0x00000070fdffc3d0) Line 6292	C++
 	clrjit.dll!jitNativeCode(CORINFO_METHOD_STRUCT_ * methodHnd=0x00007fff451354a8, CORINFO_MODULE_STRUCT_ * classPtr=0x00007fff45054c98, ICorJitInfo * compHnd=0x00000070fdffc7e0, CORINFO_METHOD_INFO * methodInfo=0x00000070fdffc6d0, void * * methodCodePtr=0x00000070fdffc3b0, unsigned int * methodCodeSize=0x00000070fdffc468, JitFlags * compileFlags=0x00000070fdffc3d0, void * inlineInfoPtr) Line 7783	C++
 	clrjit.dll!CILJit::compileMethod(ICorJitInfo * compHnd=0x00000070fdffc7e0, CORINFO_METHOD_INFO * methodInfo=0x00000070fdffc6d0, unsigned int flags=2147483652, unsigned char * * entryAddress=0x00000070fdffc478, unsigned int * nativeSizeOfCode=0x00000070fdffc468) Line 299	C++
 	[Managed to Native Transition]	
 	[Native to Managed Transition]	
 	clrjit.dll!Compiler::impImportBlockCode(BasicBlock * block=0x000001d495cf2a90) Line 8397	C++
 	clrjit.dll!Compiler::impImportBlock(BasicBlock * block=0x000001d495cf2a90) Line 11237	C++
 	clrjit.dll!Compiler::impImport() Line 12187	C++
 	clrjit.dll!Compiler::fgImport() Line 580	C++
 	[Inline Frame] clrjit.dll!Phase::Run() Line 61	C++
 	[Inline Frame] clrjit.dll!DoPhase(Compiler *) Line 136	C++
 	clrjit.dll!Compiler::compCompile(void * * methodCodePtr=0x00000070fdffc3b0, unsigned int * methodCodeSize=0x00000070fdffc468, JitFlags * compileFlags=0x00000070fdffc3d0) Line 4542	C++
 	clrjit.dll!Compiler::compCompileHelper(CORINFO_MODULE_STRUCT_ * classPtr, ICorJitInfo * compHnd=0x00000070fdffc7e0, CORINFO_METHOD_INFO * methodInfo=0x00000070fdffc6d0, void * * methodCodePtr=0x00000070fdffc3b0, unsigned int * methodCodeSize=0x00000070fdffc468, JitFlags * compileFlags=0x00000070fdffc3d0) Line 7150	C++
 	clrjit.dll!Compiler::compCompile(CORINFO_MODULE_STRUCT_ * classPtr=0x00007fff45054c98, void * * methodCodePtr=0x00000070fdffc3b0, unsigned int * methodCodeSize=0x00000070fdffc468, JitFlags * compileFlags=0x00000070fdffc3d0) Line 6292	C++
 	clrjit.dll!jitNativeCode(CORINFO_METHOD_STRUCT_ * methodHnd=0x00007fff451354a8, CORINFO_MODULE_STRUCT_ * classPtr=0x00007fff45054c98, ICorJitInfo * compHnd=0x00000070fdffc7e0, CORINFO_METHOD_INFO * methodInfo=0x00000070fdffc6d0, void * * methodCodePtr=0x00000070fdffc3b0, unsigned int * methodCodeSize=0x00000070fdffc468, JitFlags * compileFlags=0x00000070fdffc3d0, void * inlineInfoPtr) Line 7783	C++
 	clrjit.dll!CILJit::compileMethod(ICorJitInfo * compHnd=0x00000070fdffc7e0, CORINFO_METHOD_INFO * methodInfo=0x00000070fdffc6d0, unsigned int flags=2147483652, unsigned char * * entryAddress=0x00000070fdffc478, unsigned int * nativeSizeOfCode=0x00000070fdffc468) Line 299	C++
 	[Managed to Native Transition]	
 	acdbmgd.dll!<<<<<< Create .NET wrapper object 1 via C++/CLI >>>>>>
 	[Native to Managed Transition]	
 	acdb25.dll!<<<<<< Reactors fired on object 1 modification >>>>>>
        acdb25.dll!<<<<<< Object 1 is modified during file open >>>>>>
 	acad.exe!<<<<<<< Open drawing >>>>>>

Reproduction Steps

It's quite hard for me to have such a sample.

Expected behavior

No crash.

Actual behavior

Crash.

Regression?

No idea.

Known Workarounds

Pre-load the mgd dll.

Configuration

.NET 8.0.100
Windows
x64

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions