G
Guest
I originally posted this in dotnet.languages.vc, and it was suggested that I
post it in here as well...so here goes
I believe I've found a bug in either the compiler or in the runtime....for
some reason when accessing a specific unmanaged object from 2 appdomains it
causes a fatal execution engine error. It took me over a week to narrow it
down, but below I've attached a nice simple snippet of code that showcases
this issue:
Anyone have any idea what exactly is the root cause of this or how to fix it
properly? It seems that if I change the code much (such as remove the
'virtual' from either of the methods, or change the return types, or change
the dictionary to something else) the problem goes away, but I'm more worried
about where else in my code this affects and I'm hoping for a more viable
solution than "search through 500K lines of code and look for that
pattern"....not realistic
If anyone wants more detail I've put a rar up which contains the source, a
debug build with symbols, the eventlog entry, and an adplus dump with
corresponding reports:
http://www.virgeweb.com/redec/crap/RuntimeFailureTest.rar
<snippet>
#include <msclr/appdomain.h>
using namespace System;
using namespace System::Collections::Generic;
using namespace msclr;
ref class MyManagedClass
{
};
class MyUnmanagedClass
{
public:
virtual MyManagedClass^ Foo() { return nullptr; }
virtual Object^ CrashyCrashy()
{
Dictionary<String^, MyManagedClass^> ^bar = gcnew
Dictionary<String^, MyManagedClass^>();
bar->Add("", nullptr);
return nullptr;
}
};
void Test(MyUnmanagedClass *foo)
{
foo->CrashyCrashy();
}
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
MyUnmanagedClass foo;
AppDomain ^domain1 = AppDomain::CreateDomain("TestDomainOfGoodness");
call_in_appdomain<MyUnmanagedClass*>(domain1->Id, &Test, &foo);
return 0;
}
</snippet>
post it in here as well...so here goes
I believe I've found a bug in either the compiler or in the runtime....for
some reason when accessing a specific unmanaged object from 2 appdomains it
causes a fatal execution engine error. It took me over a week to narrow it
down, but below I've attached a nice simple snippet of code that showcases
this issue:
Anyone have any idea what exactly is the root cause of this or how to fix it
properly? It seems that if I change the code much (such as remove the
'virtual' from either of the methods, or change the return types, or change
the dictionary to something else) the problem goes away, but I'm more worried
about where else in my code this affects and I'm hoping for a more viable
solution than "search through 500K lines of code and look for that
pattern"....not realistic
If anyone wants more detail I've put a rar up which contains the source, a
debug build with symbols, the eventlog entry, and an adplus dump with
corresponding reports:
http://www.virgeweb.com/redec/crap/RuntimeFailureTest.rar
<snippet>
#include <msclr/appdomain.h>
using namespace System;
using namespace System::Collections::Generic;
using namespace msclr;
ref class MyManagedClass
{
};
class MyUnmanagedClass
{
public:
virtual MyManagedClass^ Foo() { return nullptr; }
virtual Object^ CrashyCrashy()
{
Dictionary<String^, MyManagedClass^> ^bar = gcnew
Dictionary<String^, MyManagedClass^>();
bar->Add("", nullptr);
return nullptr;
}
};
void Test(MyUnmanagedClass *foo)
{
foo->CrashyCrashy();
}
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
MyUnmanagedClass foo;
AppDomain ^domain1 = AppDomain::CreateDomain("TestDomainOfGoodness");
call_in_appdomain<MyUnmanagedClass*>(domain1->Id, &Test, &foo);
return 0;
}
</snippet>