Regression: MDA FatalExecutionEngineError (with repo) calling release x32 managed c++ lib, but ok with x64 and x32 debug version. - by Wuzi

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 691685 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 9/29/2011 7:51:28 AM
Access Restriction Public


Attempting to migrate from Visual Studio 2008 to 2010sp1 (.NET 4) uncovered this bug. Managed C++ code has two classes - one managed and one native. Calling a managed c++ method from c# that creates an instance of native class on stack in a managed class works fine if compiled as x64 (both debug and release) or Win32 debug, but fails when the managed lib was compiled as Win32 release.

I am attaching a full repo demonstrating the bug, and the short version here:

#include <vcclr.h>
#include <msclr\marshal.h>

using namespace System;
using namespace System::Runtime::InteropServices;
using namespace msclr::interop;

namespace BugLib {

	class NativeStr

		NativeStr(String^ str)
			_value = Marshal::StringToHGlobalAnsi(str);

			IntPtr v = _value;
			_value = IntPtr::Zero;

		operator const char*()
			return static_cast<char*>(_value.ToPointer());

		IntPtr _value;

	public ref class Class1
		int Test1(String^ str) // This method works fine in any build
			IntPtr v = IntPtr::Zero;
				v = Marshal::StringToHGlobalAnsi(str);
				return (int) static_cast<char*>(v.ToPointer());

		int Test2(String^ str)  // calling from C# causes exception if c++ compiled x32 Release
			NativeStr pStr(str);

			// This is not needed, but included for the sake of testing the return value
			return (int)(const char*)pStr;
Sign in to post a comment.
Posted by Wuzi on 2/28/2012 at 7:56 AM
Is there a hotfix for the VS 10?
Posted by Microsoft on 2/6/2012 at 5:54 PM

Thank you for your report. This issue is fixed in the latest version of the compiler. A fix will be available in our upcoming Beta release of Visual Studio.

Marian Luparu
Visual C++
Posted by Wuzi on 1/27/2012 at 9:01 AM
Any comments from the dev team?
Posted by MS-Moderator10 [Feedback Moderator] on 9/29/2011 at 8:32 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 9/29/2011 at 8:43 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(