Skip to content

Add support for standalone GC back compatibility #78484

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

Merged
merged 1 commit into from
Nov 21, 2022
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
1 change: 1 addition & 0 deletions src/coreclr/gc/gccommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ IGCHandleManager* g_theGCHandleManager;

#ifdef BUILD_AS_STANDALONE
IGCToCLR* g_theGCToCLR;
VersionInfo g_runtimeSupportedVersion;
#endif // BUILD_AS_STANDALONE

#ifdef GC_CONFIG_DRIVEN
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/gc/gcenv.ee.standalone.inl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// will be forwarded to this interface instance.
extern IGCToCLR* g_theGCToCLR;

// GC version that the current runtime supports
extern VersionInfo g_runtimeSupportedVersion;

struct StressLogMsg;

// When we are building the GC in a standalone environment, we
Expand Down
9 changes: 8 additions & 1 deletion src/coreclr/gc/gcload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ extern void PopulateHandleTableDacVars(GcDacVars* dacVars);

GC_EXPORT
void
GC_VersionInfo(/* Out */ VersionInfo* info)
GC_VersionInfo(/* InOut */ VersionInfo* info)
{
#ifdef BUILD_AS_STANDALONE
// On entry, the info argument contains the interface version that the runtime supports.
// It is later used to enable backwards compatibility between the GC and the runtime.
// For example, GC would only call functions on g_theGCToCLR interface that the runtime
// supports.
g_runtimeSupportedVersion = *info;
#endif
info->MajorVersion = GC_INTERFACE_MAJOR_VERSION;
info->MinorVersion = GC_INTERFACE_MINOR_VERSION;
info->BuildVersion = 0;
Expand Down
10 changes: 7 additions & 3 deletions src/coreclr/vm/gcheaputilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,21 @@ HRESULT LoadAndInitializeGC(LPCWSTR standaloneGcLocation)
}

g_gc_load_status = GC_LOAD_STATUS_GET_VERSIONINFO;
g_gc_version_info.MajorVersion = GC_INTERFACE_MAJOR_VERSION;
g_gc_version_info.MinorVersion = GC_INTERFACE_MINOR_VERSION;
g_gc_version_info.BuildVersion = 0;
versionInfo(&g_gc_version_info);
g_gc_load_status = GC_LOAD_STATUS_CALL_VERSIONINFO;

if (g_gc_version_info.MajorVersion != GC_INTERFACE_MAJOR_VERSION)
if (g_gc_version_info.MajorVersion < GC_INTERFACE_MAJOR_VERSION)
{
LOG((LF_GC, LL_FATALERROR, "Loaded GC has incompatible major version number (expected %d, got %d)\n",
LOG((LF_GC, LL_FATALERROR, "Loaded GC has incompatible major version number (expected at least %d, got %d)\n",
GC_INTERFACE_MAJOR_VERSION, g_gc_version_info.MajorVersion));
return E_FAIL;
}

if (g_gc_version_info.MinorVersion < GC_INTERFACE_MINOR_VERSION)
if ((g_gc_version_info.MajorVersion == GC_INTERFACE_MAJOR_VERSION) &&
(g_gc_version_info.MinorVersion < GC_INTERFACE_MINOR_VERSION))
{
LOG((LF_GC, LL_INFO100, "Loaded GC has lower minor version number (%d) than EE was compiled against (%d)\n",
g_gc_version_info.MinorVersion, GC_INTERFACE_MINOR_VERSION));
Expand Down