Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix GC interfaces versioning (#81188)
* Fix GC interfaces versioning

The change that introduced GC interfaces versioning had a bug preventing
it from using .NET 8 GC being used with .NET 7 runtime. The
GC_VersionInfo return value should have been the minimum supported
version, not the current one. But more importantly there was also
some confusion on what interface the GC_INTERFACE_MAJOR_VERSION
represents. While the change considered it to be a version of the
IGCToCLR interface, it really means the version of the IGCHeap
interface. This change creates a separate version,
EE_INTERFACE_MAJOR_VERSION for versioning o the IGCToCLR interface to
rectify that.
@Maoni0 also didn't like the way of creating a new version of
IGCToCLR interface for each major version change, so I am changing it to
single IGCToCLR interface.
  • Loading branch information
janvorli committed Jan 26, 2023
commit 1f70fc362f1dcb5a8f6e02b502869860d2c910b1
2 changes: 1 addition & 1 deletion src/coreclr/gc/gccommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ IGCHeapInternal* g_theGCHeap;
IGCHandleManager* g_theGCHandleManager;

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

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/gc/gcenv.ee.standalone.inl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// The singular interface instance. All calls in GCToEEInterface
// will be forwarded to this interface instance.
extern IGCToCLR2* g_theGCToCLR;
extern IGCToCLR* g_theGCToCLR;

// GC version that the current runtime supports
extern VersionInfo g_runtimeSupportedVersion;
Expand Down Expand Up @@ -316,7 +316,7 @@ inline void GCToEEInterface::DiagAddNewRegion(int generation, uint8_t* rangeStar

inline void GCToEEInterface::LogErrorToHost(const char *message)
{
if (g_runtimeSupportedVersion.MajorVersion >= GC_INTERFACE2_MAJOR_VERSION)
if (g_runtimeSupportedVersion.MajorVersion >= 1)
{
g_theGCToCLR->LogErrorToHost(message);
}
Expand Down
5 changes: 1 addition & 4 deletions src/coreclr/gc/gcinterface.ee.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,8 @@ class IGCToCLR {

virtual
void DiagAddNewRegion(int generation, uint8_t* rangeStart, uint8_t* rangeEnd, uint8_t* rangeEndReserved) = 0;
};

class IGCToCLR2 : public IGCToCLR {
public:

// The following method is available only with EE_INTERFACE_MAJOR_VERSION >= 1
virtual
void LogErrorToHost(const char *message) = 0;
};
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/gc/gcinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
#ifndef _GC_INTERFACE_H_
#define _GC_INTERFACE_H_

// The major version of the GC/EE interface. Breaking changes to this interface
// The major version of the IGCHeap interface. Breaking changes to this interface
// require bumps in the major version number.
#define GC_INTERFACE_MAJOR_VERSION 6
#define GC_INTERFACE_MAJOR_VERSION 5

// The minor version of the GC/EE interface. Non-breaking changes are required
// The minor version of the IGCHeap interface. Non-breaking changes are required
// to bump the minor version number. GCs and EEs with minor version number
// mismatches can still interopate correctly, with some care.
// mismatches can still interoperate correctly, with some care.
#define GC_INTERFACE_MINOR_VERSION 1

// The major version of the GC/EE interface. Breaking changes to this interface
// The major version of the IGCToCLR interface. Breaking changes to this interface
// require bumps in the major version number.
#define GC_INTERFACE2_MAJOR_VERSION 6
#define EE_INTERFACE_MAJOR_VERSION 1

struct ScanContext;
struct gc_alloc_context;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/gcload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ GC_Initialize(

#ifdef BUILD_AS_STANDALONE
assert(clrToGC != nullptr);
g_theGCToCLR = (IGCToCLR2*)clrToGC;
g_theGCToCLR = clrToGC;
#else
UNREFERENCED_PARAMETER(clrToGC);
assert(clrToGC == nullptr);
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/gcheaputilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ 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.MajorVersion = EE_INTERFACE_MAJOR_VERSION;
g_gc_version_info.MinorVersion = 0;
g_gc_version_info.BuildVersion = 0;
versionInfo(&g_gc_version_info);
g_gc_load_status = GC_LOAD_STATUS_CALL_VERSIONINFO;
Expand Down