-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
HOST_RUNTIME_CONTRACT has invalid value on custom .NET runtime host on Linux #97086
Comments
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov Issue DetailsDescriptionI am the maintainer of a project (CounterStrikeSharp) which embeds the .NET runtime into a Counter-Strike 2 game server as a way for script authors to modify game server code. It currently supports Linux & Windows on 64 bit systems, and has been currently functioning fine with the .NET 7 CLR. It is worth noting that we ship the entire .NET runtime i.e. by extracting this linked ASP.NET runtime tar.gz with our release builds, so the host is running completely from our own directory. We have tried recently to upgrade to .NET 8, however the Core CLR now crashes (only on Linux), when calling the Reproduction StepsReproduction is quite hard given the extenuating circumstances of our native host, requiring a running CS2 server to reproduce. Trace:
Expected behavior.NET runtime loads and retrieves the managed function pointer successfully without crashing Actual behavior.NET runtime causes a segfault when trying to call Regression?This was working correctly for us in .NET 7.0.11 Known WorkaroundsNo response ConfigurationVersion: .NET 8.0.1 Other informationRunning on Windows & Linux respectively, with Windows: Property NATIVE_DLL_SEARCH_DIRECTORIES = ;G:\cs2\game\csgo\addons\counterstrikesharp\dotnet\shared\Microsoft.NETCore.App\8.0.1\;
Property PLATFORM_RESOURCE_ROOTS = ;
Property APP_CONTEXT_BASE_DIRECTORY =
Property APP_CONTEXT_DEPS_FILES = G:\cs2\game\csgo\addons\counterstrikesharp\dotnet\shared\Microsoft.NETCore.App\8.0.1\Microsoft.NETCore.App.deps.json
Property PROBING_DIRECTORIES =
Property RUNTIME_IDENTIFIER = win-x64
Property System.Reflection.Metadata.MetadataUpdater.IsSupported = false
Property System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization = false
Property HOST_RUNTIME_CONTRACT = 0x285916ded88 Linux: Property System.Reflection.Metadata.MetadataUpdater.IsSupported = false
Property RUNTIME_IDENTIFIER = linux-x64
Property HOST_RUNTIME_CONTRACT = 0x
Property System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization = false
Property FX_DEPS_FILE = /home/michael/Steam/cs2-ds/game/csgo/addons/counterstrikesharp/dotnet/shared/Microsoft.NETCore.App/8.0.1/Microsoft.NETCore.App.deps.json
Property APP_CONTEXT_DEPS_FILES = /home/michael/Steam/cs2-ds/game/csgo/addons/counterstrikesharp/dotnet/shared/Microsoft.NETCore.App/8.0.1/Microsoft.NETCore.App.deps.json
Property APP_CONTEXT_BASE_DIRECTORY =
Property PLATFORM_RESOURCE_ROOTS = :
Property PROBING_DIRECTORIES = The only thing worth noting is that One of our users has found the pointer value from the ptr_stream located here, and manually set it later in the startup here and that does allow the runtime to startup, though I am not sure why this value is never passed through correctly. Please let me know if there is anything else we can provide to help provide more context. We are tracking the issue in our repo here: roflmuffin/CounterStrikeSharp#260
|
We have a very similar issue with the Flax engine but I found that the property value is not 0 but a weirdly formatted address:
This looked awfully familiar to a number formatted by a locale setting so I tried to run the same binary with LC_NUMERIC="" LANG="C" and indeed the offending code won't throw a segfault anymore. Maybe the 0x you're seeing is a failed attempt to format an address and this is the same problem? Anyway, passing memory addresses by strings is weird enough but at least it shouldn't try to format it using a locale setting. |
Thanks for the investigation here. This was changed such that it should no longer do this (#95801). If this is the issue, we may want to backport to 8. @roflmuffin / @nothingTVatYT would there be any way to check your scenario against a .NET 9 build from https://github.com/dotnet/installer? |
You mean a build using main or should I try a certain branch? |
It's not exactly easy to check it completely but what I did is: So the fix might work but I still see the string to uint64 pointer in exports.cpp. The stack trace I get is:
|
I think at this point I can confirm the fix is working. In another test I cloned the dotnet-installer project, built a dotnet9 runtime, installed it in /usr/share/dotnet and tried to run the Flax game editor. |
Thanks, @nothingTVatYT! I will look at backporting. |
This should be addressed in 8.0.3 with #97891 |
Description
I am the maintainer of a project (CounterStrikeSharp) which embeds the .NET runtime into a Counter-Strike 2 game server as a way for script authors to modify game server code. It currently supports Linux & Windows on 64 bit systems, and has been currently functioning fine with the .NET 7 CLR. It is worth noting that we ship the entire .NET runtime i.e. by extracting this linked ASP.NET runtime tar.gz with our release builds, so the host is running completely from our own directory.
We have tried recently to upgrade to .NET 8, however the Core CLR now crashes (only on Linux), when calling the
hostfxr_get_runtime_delegate
method (seen here)Reproduction Steps
Reproduction is quite hard given the extenuating circumstances of our native host, requiring a running CS2 server to reproduce.
Trace:
Expected behavior
.NET runtime loads and retrieves the managed function pointer successfully without crashing
Actual behavior
.NET runtime causes a segfault when trying to call
hostfxr_get_runtime_delegate
Regression?
This was working correctly for us in .NET 7.0.11
Known Workarounds
No response
Configuration
Version: .NET 8.0.1
Linux: Tested on Fedora 38, multiple Linux users have reported the issue
Arch: x64
Other information
Running on Windows & Linux respectively, with
COREHOST_TRACE=1
in environment variables, we see the following output before the crash:Windows:
Linux:
The only thing worth noting is that
HOST_RUNTIME_CONTRACT
is set to0x
on the Linux build. After further investigation, the line that appears to be causing the crash is this line in mscoree/exports.cpp.One of our users has found the pointer value from the ptr_stream located here, and manually set it later in the startup here and that does allow the runtime to startup, though I am not sure why this value is never passed through correctly.
Please let me know if there is anything else we can provide to help provide more context.
We are tracking the issue in our repo here: roflmuffin/CounterStrikeSharp#260
The text was updated successfully, but these errors were encountered: