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

CLR crashes soon after CreateRuntime called on Linux #1282

Open
iskiselev opened this issue Aug 15, 2024 · 0 comments
Open

CLR crashes soon after CreateRuntime called on Linux #1282

iskiselev opened this issue Aug 15, 2024 · 0 comments

Comments

@iskiselev
Copy link
Contributor

iskiselev commented Aug 15, 2024

On linux, after attempt to CreateSnapshotAndAttach for it's own process CLR crashes soon after the thread that called CreateRuntime() finishes. Looks like it happens when some resources disposed, so it may work some not-long time. To reproduce it is enough to call CreateRuntime() in separate thread and wait a little bit after thread will be finished.
Repro steps:

  • sources
using System.Diagnostics;
using Microsoft.Diagnostics.Runtime;

var t = new Thread(() =>
    {
        try
        {
            using var dataTarget = DataTarget.CreateSnapshotAndAttach(Process.GetCurrentProcess().Id);
            using var runtime = dataTarget.ClrVersions[0].CreateRuntime();
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
    });
t.Start();
t.Join();

Console.WriteLine("Done Get Runtime!");

while (true)
{
    Console.WriteLine("!!!!!!!! " + DateTime.Now);
    Thread.Sleep(1000);
}
  • project
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <OutputType>Exe</OutputType>
    <InvariantGlobalization>true</InvariantGlobalization>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Diagnostics.NETCore.Client" Version="0.2.532401" />
    <PackageReference Include="Microsoft.Diagnostics.Runtime" Version="4.0.0-beta.24360.3" />
  </ItemGroup>

</Project>
  • docker command to test (with docker running linux containers): docker run --rm --cap-add SYS_PTRACE -v %CD%:/app -w /app mcr.microsoft.com/dotnet/sdk:8.0 dotnet run

I've reproduced issue with different versions of Microsoft.Diagnostics.Runtime/Microsoft.Diagnostics.NETCore.Client and DOTNET runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant