Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/9.0-staging] Fix C++/CLI applications which use __declspec(appdomain) #110495

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4360,7 +4360,10 @@ void MethodTable::DoFullyLoad(Generics::RecursionGraph * const pVisited, const
ClassLoader::ValidateMethodsWithCovariantReturnTypes(this);
}

if ((level == CLASS_LOADED) && CORDisableJITOptimizations(this->GetModule()->GetDebuggerInfoBits()) && !HasInstantiation())
if ((level == CLASS_LOADED) &&
CORDisableJITOptimizations(this->GetModule()->GetDebuggerInfoBits()) &&
!HasInstantiation() &&
!GetModule()->GetDomainAssembly()->IsLoading()) // Do not do this during the vtable fixup stage of C++/CLI assembly loading. See https://github.com/dotnet/runtime/issues/110365
{
if (g_fEEStarted)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,22 @@ extern "C" DLL_EXPORT int __cdecl NativeEntryPoint()
}

#pragma managed

// Needed to provide a regression case for https://github.com/dotnet/runtime/issues/110365
[assembly:System::Diagnostics::DebuggableAttribute(true, true)];
[module:System::Diagnostics::DebuggableAttribute(true, true)];

public value struct ValueToReturnStorage
{
int valueToReturn;
bool valueSet;
};

// store the value to return in an appdomain local static variable to allow this test to be a regression test for https://github.com/dotnet/runtime/issues/110365
static __declspec(appdomain) ValueToReturnStorage s_valueToReturnStorage;

public ref class TestClass
{
private:
static int s_valueToReturn = 100;
public:
int ManagedEntryPoint()
{
Expand All @@ -29,12 +41,16 @@ public ref class TestClass

static void ChangeReturnedValue(int i)
{
s_valueToReturn = i;
s_valueToReturnStorage.valueToReturn = i;
s_valueToReturnStorage.valueSet = true;
}

static int GetReturnValue()
{
return s_valueToReturn;
if (s_valueToReturnStorage.valueSet)
return s_valueToReturnStorage.valueToReturn;
else
return 100;
}
};

Expand Down
Loading