Skip to content

"HTTP call causes SegmentationFault in .NET 10 container on OpenShift (works in .NET 9)" #122303

Closed

Description

@RufusJWB

Compiling the following program with dotnet SDK 9 and running it in a dotnet runtime 9 based container on OpenShift works as expected:

namespace CertWatch
{
    internal static class Program
    {
        public static void Main(string[] args)
        {
            Console.Out.WriteLine("Creating client");

            HttpClient client = new HttpClient();

            Console.Out.WriteLine("Client created");
            try
            {
                var response = client.GetAsync("https://certspotter.com/").Result;
                Console.Out.WriteLine($"Response received {response.StatusCode}");
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine($"Exception: {ex.Message}");
                Console.Out.WriteLine(ex.ToString());
            }
            finally
            {
                Console.Out.WriteLine("Leaving");
            }
        }
    }
}
Creating client
Client created
Exception: One or more errors occurred. (The proxy tunnel request to proxy 'http://proxy.dc4ca.siemens.de:8080/' failed with status code '403'.")
System.AggregateException: One or more errors occurred. (The proxy tunnel request to proxy 'http://proxy.dc4ca.siemens.de:8080/' failed with status code '403'.")
 ---> System.Net.Http.HttpRequestException: The proxy tunnel request to proxy 'http://proxy.dc4ca.siemens.de:8080/' failed with status code '403'."
   at System.Net.Http.HttpConnectionPool.EstablishProxyTunnelAsync(Boolean async, CancellationToken cancellationToken)
   ...
Leaving

Building the very same program in dotnet 10 and running it in a dotnet 10 container leads to a segmentation fault:

Creating client
Client created

This is what I can see in OpenShift logs:

The container last terminated with exit code 139 because of Error.

This is the dockerfile used:

# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

# This stage is used when running from VS in fast mode (Default for Debug configuration)
FROM mcr.microsoft.com/dotnet/runtime:10.0 AS base
LABEL build.commit=$GIT_HASH
LABEL org.opencontainers.image.source="CertWatch"
LABEL org.opencontainers.image.revision=$GIT_HASH
USER $APP_UID
WORKDIR /app


# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG BUILD_CONFIGURATION=Release
ARG GIT_HASH
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 \
    DOTNET_CLI_TELEMETRY_OPTOUT=1
WORKDIR /src

COPY ["sources/CertWatch.csproj", "sources/"]
RUN dotnet restore "./sources/CertWatch.csproj"
COPY ["sources/", "sources/"]
WORKDIR "/src/sources"
RUN dotnet build "./CertWatch.csproj" -c $BUILD_CONFIGURATION -o /app/build /p:GitHash=${GIT_HASH}

# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
ARG GIT_HASH
RUN dotnet publish "./CertWatch.csproj" -c $BUILD_CONFIGURATION -r linux-x64 --self-contained true -o /app/publish /p:PublishTrimmed=true /p:UseAppHost=true

# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0 AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["./CertWatch"]

I also tried to build with dotnet 9 sdk and run in dotnet 10 and this also fails.

As reference the pipeline configuration to build the container:

.gitlab-ci.yml

Activity

  1. added
    untriaged
    on Nov 21, 2025
  2. lbussell commented on Nov 24, 2025

    @lbussell
    Member

    I can't reproduce this using Docker Desktop v4.51.0 on Windows (building for linux-x64) or Mac (linux-arm64) with v4.52.0. I created a new console app, copied in your Program.cs, and used your exact Dockerfile except I removed the git commit stuff.

    @wtgodbe does this look like an aspnet issue?

  3. RufusJWB commented on Nov 24, 2025

    @RufusJWB
    Author

    On Docker I can't reproduce it neither. It must have something to do with OpenShift specifics.

  4. omajid commented on Nov 24, 2025

    @omajid
    Member

    @tmds could not reproduce this on OpenShift either. He thinks this might be another instance of #121578 though.

  5. tmds commented on Nov 25, 2025

    @tmds
    Member

    Note that I don't have a proxy server, so I did not reproduce what is probably an important part: the exception being thrown by 403 of the proxy server.

    You can try if things are different with Red Hat's .NET build. You can build an image using:

    dotnet publish /p:ContainerBaseImage=registry.access.redhat.com/dotnet/runtime:10.0 /t:PublishContainer -v detailed
    
  6. RufusJWB commented on Nov 29, 2025

    @RufusJWB
    Author

    You can try if things are different with Red Hat's .NET build.

    I tried it with the Red Hat build and here it is working:

    Creating client
    Client created
    Exception: One or more errors occurred. (The proxy tunnel request to proxy 'http://proxy.dc4ca.siemens.de:8080/' failed with status code '403'.")
    System.AggregateException: One or more errors occurred. (The proxy tunnel request to proxy 'http://proxy.dc4ca.siemens.de:8080/' failed with status code '403'.")
     ---> System.Net.Http.HttpRequestException: The proxy tunnel request to proxy 'http://proxy.dc4ca.siemens.de:8080/' failed with status code '403'."
       at System.Net.Http.HttpConnectionPool.EstablishProxyTunnelAsync(Boolean async, CancellationToken cancellationToken)
       at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
       at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
       at System.Net.Http.HttpConnectionPool.InjectNewHttp11ConnectionAsync(QueueItem queueItem)
       at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken)
       at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
       at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
       at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
       --- End of inner exception stack trace ---
       at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
       at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
       at System.Threading.Tasks.Task`1.get_Result()
       at CertWatch.Program.Main(String[] args) in /src/sources/Program.cs:line 14
    Leaving
    

    This is the dockerfile adapted to RedHat:

    # See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
    
    # This stage is used when running from VS in fast mode (Default for Debug configuration)
    FROM mcr.microsoft.com/dotnet/runtime:10.0 AS base
    LABEL build.commit=$GIT_HASH
    LABEL org.opencontainers.image.source="CertWatch"
    LABEL org.opencontainers.image.revision=$GIT_HASH
    USER $APP_UID
    WORKDIR /app
    
    # This stage is used to build the service project
    FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
    ARG BUILD_CONFIGURATION=Release
    ARG GIT_HASH
    ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 \
        DOTNET_CLI_TELEMETRY_OPTOUT=1
    WORKDIR /src
    
    COPY ["sources/CertWatch.csproj", "sources/"]
    RUN dotnet restore "./sources/CertWatch.csproj"
    COPY ["sources/", "sources/"]
    WORKDIR "/src/sources"
    RUN dotnet build "./CertWatch.csproj" -c $BUILD_CONFIGURATION -o /app/build /p:GitHash=${GIT_HASH}
    
    # This stage is used to publish the service project to be copied to the final stage
    FROM build AS publish
    ARG BUILD_CONFIGURATION=Release
    ARG GIT_HASH
    RUN dotnet publish "./CertWatch.csproj" -c $BUILD_CONFIGURATION -r linux-x64 --self-contained true -o /app/publish /p:PublishTrimmed=true /p:UseAppHost=true
    
    # This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
    FROM registry.access.redhat.com/dotnet/runtime:10.0 AS final
    WORKDIR /app
    COPY --from=publish /app/publish .
    ENTRYPOINT ["./CertWatch"]
    

    being build with Kaniko:

    stages:
    - build_image
    
    variables:
        http_proxy: $CODE_PROXY
        https_proxy: $CODE_PROXY
        no_proxy: code.siemens.com,docker.siemens.com
    
        # Docker uses upper-case variables
        HTTP_PROXY: $CODE_PROXY
        HTTPS_PROXY: $CODE_PROXY
        NO_PROXY: $CODE_NO_PROXY
    
    build_with_kaniko:
      stage: build_image
      image:
        name: gcr.io/kaniko-project/executor:debug
        entrypoint: [""]
      before_script:
        - echo "machine code.siemens.com login gitlab-ci-token password ${CI_JOB_TOKEN}" >/kaniko/netrc
        - echo "{
            \"auths\":{
                \"$CI_REGISTRY\":{
                    \"username\":\"$REGISTRY_USER\",
                    \"password\":\"$REGISTRY_PASSWORD\"
                }
              }
            }" > /kaniko/.docker/config.json
      script:
        - EXTRA_ARGS=""
        - if [ "$CI_COMMIT_BRANCH" == "main" ]; then EXTRA_ARGS="--destination $CI_REGISTRY_IMAGE:latest"; fi
        - |
          /kaniko/executor \
          --dockerfile $CI_PROJECT_DIR/sources/Dockerfile \
          --context $CI_PROJECT_DIR \
          --cache=true \
          --cache-repo $CI_REGISTRY_IMAGE/cache \
          --cache-copy-layers \
          --use-new-run \
          --cache-ttl 48h \
          --snapshot-mode=redo \
          --build-arg GIT_HASH=$CI_COMMIT_SHORT_SHA \
          --build-arg http_proxy \
          --build-arg https_proxy \
          --build-arg no_proxy \
          --build-arg HTTP_PROXY \
          --build-arg HTTPS_PROXY \
          --build-arg NO_PROXY \
          --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA \
          --destination $CI_REGISTRY_IMAGE:latest
          $EXTRA_ARGS
    
  7. tmds commented on Dec 1, 2025

    @tmds
    Member

    The way you published the app ends up using the Microsoft .NET build with Red Hat base image for runtime-deps. That suggests the issue is triggered by the runtime-deps in the Microsoft image.

    cc @jkotas

  8. tmds commented on Dec 1, 2025

    @tmds
    Member

    @RufusJWB one additional thing you can try is to set ENV HOME=/tmp with Microsoft runtime-deps. I don't expect it to have an effect, but it's good to be sure. By adding this, we ensure that if the container runs with a random UID on OpenShift, the container user has a writable home.

  9. RufusJWB commented on Dec 1, 2025

    @RufusJWB
    Author

    @RufusJWB one additional thing you can try is to set ENV HOME=/tmp with Microsoft runtime-deps. I don't expect it to have an effect, but it's good to be sure.

    I adjusted my dockerfile to

    # This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
    # FROM registry.access.redhat.com/dotnet/runtime:10.0 AS final
    FROM mcr.microsoft.com/dotnet/runtime:10.0 AS final
    ENV HOME=/tmp
    WORKDIR /app
    COPY --from=publish /app/publish .
    ENTRYPOINT ["./CertWatch"]
    

    but nothing changed. Still running into The container last terminated with exit code 139 because of Error.

  10. added
    needs-area-label
    on Dec 8, 2025
  11. moved this from Backlog to Tracking in .NET Dockeron Dec 8, 2025
  12. RufusJWB commented on Dec 9, 2025

    @RufusJWB
    Author

    @tmds @lbussell is there anything I can do to support the triage process?

  13. 25 remaining items

  14. added and removed
    untriaged
    on Aug 16, 2026
  15. added this to the 12.0.0 milestone on Aug 16, 2026
  16. dotnet-policy-service commented on Aug 16, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones
    See info in area-owners.md if you want to be subscribed.

  17. added theissue type on Aug 24, 2026
  18. wfurt commented on Aug 27, 2026

    @wfurt
    Member

    I did another pass on this @RufusJWB and here is what I see. While I can reproduce the crash with .NET 10, I was not able to crash it with .NET 11. (#122569 + #125324) The last core is from .NET 9 - you would need to recompile the self-contained app to really pick up the fixes.

    Now, this is not really the problem. The problem is that we fail to initialize OpenSSL so even if it does not crash with .NET 11, TLS & crypto will not work because problems with the OpenSSL configuration. You can run this inside the container where it is failing.

    $ openssl list -providers      # broken pod prints just "Providers:" and nothing else
    $ openssl ciphers >/dev/null && echo OK || echo BROKEN
    

    Or you can share your OpenSSL.conf -> The sock one seems just fine and I was unable to make it fail.
    You can also add if not in your config.

    [provider_sect]
    default = default_sect  
    

    let me know.

  19. added
    needs-author-action
    on Aug 27, 2026
  20. dotnet-policy-service commented on Aug 27, 2026

    @dotnet-policy-service
    Contributor

    This issue has been marked needs-author-action and may be missing some important information.

  21. dotnet-policy-service commented on Oct 14, 2026

    @dotnet-policy-service
    Contributor

    This issue has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

  22. dotnet-policy-service commented on Nov 16, 2026

    @dotnet-policy-service
    Contributor

    This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

  23. removed this from the 12.0.0 milestone on Nov 16, 2026
  24. moved this from Tracking to Done in .NET Dockeron Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-System.Net.Securityneeds-author-actionno-recent-activityregression-from-last-release

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions