Skip to content

dotnet {build, restore} crashing and hanging in Docker #45751

Open
@aep-sunlife

Description

Hi,

When I try to run dotnet build or dotnet restore in Docker, then the process crashes. Sometimes it even hangs, tying up the user's shell session.

Trace

$ docker run --rm -it hello dotnet restore

Welcome to .NET 8.0!
---------------------
SDK Version: 8.0.401

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, view the instructions: https://aka.ms/dotnet-https-linux

----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Regex1_Scan(RegexRunner, ReadOnlySpan`1)

Bad process state

Several problems are happening.

dotnet restore triggers a null pointer error, instead of generating a security report for Npgsql.

When dotnet restore runs inside a docker run --rm -it hello bash REPL session, then it triggers a null pointer error and crashes back to the container shell prompt (#).

However, when dotnet restore runs as a one-off command with docker run --rm -it hello dotnet restore, then the same null pointer error shows but the process hangs, failing to terminate the process and return control back to the host shell (e.g. $ on macOS).

For comparison, dotnet restore appears to work fine when run directly on the host (at least for macOS and Windows hosts). And a dozen other programming languages work just fine in Fedora (v41) in Docker (v27). .NET is the first one I've seen segfault with a Hello World project since Swift and Z*g.

As an aside, installing nuget via DNF and running nuget results in SIGABRT crashes. Something's rotten in the state of .NET.

Dockerfile

FROM fedora:41
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
ENV DOTNET_ROOT=/root/.dotnet
ENV PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
RUN dnf install -y \
        curl \
        krb5-libs \
        libicu \
        openssl-libs && \
    curl -LO https://dot.net/v1/dotnet-install.sh && \
    chmod +x dotnet-install.sh && \
    ./dotnet-install.sh --version 8.0.401 && \
    rm dotnet-install.sh
COPY . /src
WORKDIR /src

hello.csproj

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net8.0</TargetFramework>
        <RootNamespace>hello</RootNamespace>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Npgsql" Version="8.0.2" />
    </ItemGroup>
</Project>

Hello.cs

using Npgsql;

Console.WriteLine("Hello World!");

Console.WriteLine($"Database connector: {ServerCompatibilityMode.Redshift}");

//
// Example privacy violation.
// A social security number leaks through application logs.
//
Console.Write("SSN: ");
var ssn = Console.ReadLine();
// Console.WriteLine("Registered user.");
Console.WriteLine($"Registered user. SSN: {ssn}");

Activity

changed the title `dotnet restore` crashes `dotnet restore` crashing/hanging on Dec 13, 2024
aep-sunlife

aep-sunlife commented on Dec 13, 2024

@aep-sunlife
Author

Update: dotnet build has the same problem. Even with TreatWarningsAsErrors disabled.

changed the title `dotnet restore` crashing/hanging `dotnet {build, restore}` crashing and hanging in Docker on Dec 13, 2024
transferred this issue fromdotnet/coreon Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    `dotnet {build, restore}` crashing and hanging in Docker · Issue #45751 · dotnet/sdk