Skip to content

huoyaoyuan/clrgc-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clrgc-rs

A compatible CLR GC implemented in Rust.

It's a naive proof-of-concept learning project that demonstrates the interface and contract of CLR GC. Check also the excellent posts for implementing GC in C# NativeAOT by Kevin Goose.

Features

  • Precise mark-compact-sweep GC is implemented. Object references on the managed stack and heap objects can be correctly updated.
  • Pinning and GC handles.
  • Generational collection is not implemented. Programs explicitly observing can see different behavior.
  • Background (concurrent) GC is not implemented. Everything happens in a single STW collection. Running the managed application with multiple threads is supported, though only one thread performs the GC.
  • Finalization is correctly supported, but the behavior details may differ from CLR GC, especially when relating to generations.
  • Although the code is written in platform-neutral code, Windows x86 is known to be unsupported due to calling convention quirks.

Testing

Just set the environment variable DOTNET_GCPath to the compiled library and run any .NET 10 application. The versions of CLR and GC are required to match closely, and this project is written with the interface of .NET 10.

It's also recommended to enable Page Heap to catch heap corruption early. It can also be enabled by setting the following registry values:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\<executable.exe>]
"VerifierFlags"=dword:00000001
"PageHeapFlags"="0x3"
"GlobalFlag"="0x02200000"

About

CLR GC implemented in Rust

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Contributors