CLR Error when using RunAndCollect rather than RunAndSave

0

When dynamically generated assemblies, we regularly get this exception:

Managed Debugging Assistant 'FatalExecutionEngineError' Message=Managed Debugging Assistant 'FatalExecutionEngineError' : 'The runtime has encountered a fatal error. The address of the error was at 0xa3851e22, on thread 0x25ac. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.'

which on loading the CLR symbols is always thrown with this call stack:

           ntdll.dll!NtWaitForSingleObject ()            Unknown
           KernelBase.dll!WaitForSingleObjectEx () Unknown
           ntdll.dll!RtlpCallVectoredHandlers()        Unknown
           ntdll.dll!RtlDispatchException() Unknown
           ntdll.dll!KiUserExceptionDispatch ()        Unknown
           kernel32.dll!BaseThreadInitThunk ()       Unknown
           ntdll.dll!RtlUserThreadStart ()    Unknown

This problem does not occur when AssemblyBuilderAccess is set to RunAndSave, but it reliably occurs when setting it to RunAndCollect. It always is thrown at this call stack. Is there a CLR bug with RunAndCollect? As far as we can tell, we hold references to the Assembly and Module reflection objects for these dynamic assemblies, which should mean they are not being collected ever. This should mean there is no difference in behaviour between RunAndSave and RunAndCollect.

c#
.net
reflection
dynamic-assemblies
asked on Stack Overflow Jan 27, 2020 by Nick

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0