I have a mixed mode project, where I start native c++ code and load and use few c# 4.7.2 assemblies. It worked fine for a long time, but I have stumbled on one issue. C# only unit tests work fine. C++ only unit tests calling managed work fine, when mixed mode debugging is disabled. When I enable mixed mode debugging, I can do debug session starting from native do manage, but I get a clr.dll crash with an access violation on address 0 when I come into some specific piece of code:
Exception thrown at 0x00007FFAF53A2774 (clr.dll) in server_unittests.exe: 0xC0000005: Access violation reading location 0x0000000000000000
It is deterministic and happens when calling a base constructor from a derived class.
The code works, there are no leaks or anything and can be debugged, but dies when the session is started from unmanaged. It looks roughly as this:
public DerivedData(uint customerId, bool load) : public BaseData(int customerId, string idName, string table, HashSet<(string colName, Constants.DbTypes colType, bool client, int verbosity)> vars, BaseData initialValues = null)
and crashes right when it should step into base class constructor code.
For man-unman bridge, I use 3F/DllExport project. I have the latest vs 2017.
Please help me find the pattern, that makes it crash or point me to some GUI config, that makes it go away:)
It started to throw a different error after some options twiddling:
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'server_unittests.exe'. Additional Information: The runtime has encountered a fatal error. The address of the error was at 0xf53a2774, on thread 0x1a6c. 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.
User contributions licensed under CC BY-SA 3.0