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

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

Open
aep-sunlife opened this issue Dec 13, 2024 · 1 comment
Open

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

aep-sunlife opened this issue Dec 13, 2024 · 1 comment

Comments

@aep-sunlife
Copy link

aep-sunlife commented Dec 13, 2024

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}");
@aep-sunlife aep-sunlife changed the title dotnet restore crashes dotnet restore crashing/hanging Dec 13, 2024
@aep-sunlife
Copy link
Author

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

@aep-sunlife aep-sunlife changed the title dotnet restore crashing/hanging dotnet {build, restore} crashing and hanging in Docker Dec 13, 2024
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