Skip to content

Segmentation fault in 3.1 docker image #2308

Closed

Description

@mabead

Describe the bug
GitVersion dotnet global tool ends in segmentation fault.

Expected Behavior

It should print the version

Actual Behavior

Segmentation fault crash

Steps to Reproduce

To make sure that I have a clean environment, I start by opening a bash shell in an asp.net core 3.1 docker image:

docker run --rm -it mcr.microsoft.com/dotnet/core/sdk:3.1 bash

In this bash, I then execute these commands:

export PATH="$PATH:/root/.dotnet/tools"
dotnet tool install -g "GitVersion.Tool"
mkdir ~/git
cd ~/git
git clone https://github.com/mabead/old-github-packages-cleaner.git
cd old-github-packages-cleaner/
dotnet-gitversion -verbosity Debug

I then have this result:

root@d7406c09cb8e:~/git/old-github-packages-cleaner# dotnet-gitversion -verbosity Debug
Segmentation fault (core dumped)

What is really weird, is that the behavior is not the same on all machines even though we are running in docker!

  • my machine (windows with docker 19.03.8): no crash
  • my collegue machine (windows with docker 19.03.8): segmentation fault
  • TeamCity build agent with docker 19.03.5: no crash
  • another TeamCity build agent with docker 19.03.5: segmentation fault

Your Environment

  • Version Used: GitVersion.Tool 5.3.4
  • Operating System and version (Windows 10, Ubuntu 18.04): docker

Activity

  1. asbjornu commented on Jun 2, 2020

    @asbjornu
    Member

    Please see #2260 (comment). Debian/Ubuntu is unsupported by LibGit2Sharp. Use one of our official Docker images instead.

  2. mabead commented on Jun 2, 2020

    @mabead
    Author

    Thanks @asbjornu . Would it possible to fail early with an error message that says something like "Debian/Ubuntu is unsupported by LibGit2Sharp. Use one of our official Docker images instead (https://hub.docker.com/r/gittools/gitversion)"?

    My colleague and I spent nearly a day trying to narrow down the error. So a clear error message instead of a non-systematic crash would have made a huge difference. Thanks.

  3. asbjornu commented on Jun 2, 2020

    @asbjornu
    Member

    I would love to do that, but as I wrote in #2260 (comment):

    It would be great to do something like that. But it sounds like a PITA to maintain a list of supported operating systems for another software project. If LibGit2Sharp had a list we could use, this would be no problem. But unfortunately they don't afaik.

  4. mabead commented on Jun 2, 2020

    @mabead
    Author

    I have tried to use gittools/gitversion:latest-linux-netcoreapp2.1 and it does work successfully.

    That being said, it's a little painfull to download a 341 MB docker image instead of the 1 MB dotnet-gitversion global tool. It does slow down our build process that has to download all this before being able to run gitversion.

  5. asbjornu commented on Jun 2, 2020

    @asbjornu
    Member

    I understand your pain, but our alpine images are only 89MB and with caching in place, docker pull should not have to re-download the image on every run.

  6. mabead commented on Jun 2, 2020

    @mabead
    Author

    @asbjornu I see that you have updated the README of the docker images to refer to gittools/gitversion:5.3.5-linux-alpine.3.10-x64-netcoreapp3.1 instead of latest-linux-netcoreapp2.1. I do see a signficant change in size:

    REPOSITORY            TAG                                         IMAGE ID            CREATED             SIZE
    gittools/gitversion   5.3.5-linux-alpine.3.10-x64-netcoreapp3.1   6beafce0301e        3 days ago          183MB
    gittools/gitversion   latest-linux-netcoreapp2.1                  f2e60a3cf5c8        2 months ago        341MB
    

    Note that I see a size of 183 MB and not 89 MB. I guess you meant that you only add 89 MB on top of the alpine image.

    Thanks again for your support. It does minimize the pain to to have a smaller image ;)

  7. asbjornu commented on Jun 2, 2020

    @asbjornu
    Member

    I may have looked at "compressed size" on hub.docker.com and also remember the size wrong.

    image

  8. dejoost commented on Nov 17, 2020

    @dejoost

    managed to run it on ubuntu bionic (mcr.microsoft.com/dotnet/sdk:3.1-bionic

  9. luis-fss commented on Feb 9, 2021

    @luis-fss

    Segmentation fault (core dumped) /root/.nuget/packages/gitversion.msbuild/5.6.4/tools/GitVersion.MsBuild.targets(9,9): error MSB3073: The command "dotnet --roll-forward Major "/root/.nuget/packages/gitversion.msbuild/5.6.4/tools/netcoreapp3.1/gitversion.dll" "/src/src/GUI/PMCM" -output file -outputfile obj/gitversion.json" exited with code 139.

    Dont know why 'netcoreapp3.1' path, my project is set to net5.0, GitVersion.MsBuild 5.6.4
    Docker image: mcr.microsoft.com/dotnet/sdk:5.0-alpine

  10. asbjornu commented on Feb 9, 2021

    @asbjornu
    Member

    @Lukkian, can you please use one of the official GitVersion Docker images, such as gittools/gitversion:5.6.6?

  11. luis-fss commented on Feb 9, 2021

    @luis-fss

    Thanks @asbjornu I could but I just found out that the oficial mcr.microsoft.com/dotnet/sdk:5.0 (not the 5.0-alpine) works great with GitVersion.MsBuild 5.6.4.

    I'm not using GitVersion.MsBuild 5.6.6 because of this: #2590 (comment)

  12. vadym commented on Mar 18, 2021

    @vadym

    Segmentation fault (core dumped) /root/.nuget/packages/gitversion.msbuild/5.6.4/tools/GitVersion.MsBuild.targets(9,9): error MSB3073: The command "dotnet --roll-forward Major "/root/.nuget/packages/gitversion.msbuild/5.6.4/tools/netcoreapp3.1/gitversion.dll" "/src/src/GUI/PMCM" -output file -outputfile obj/gitversion.json" exited with code 139.

    Dont know why 'netcoreapp3.1' path, my project is set to net5.0, GitVersion.MsBuild 5.6.4
    Docker image: mcr.microsoft.com/dotnet/sdk:5.0-alpine

    I have the same issue.
    Tried to use gittools/gitversion:5.6.7-alpine.3.12-x64-5.0 but got the error: "Cannot find the .git directory" (GitLab-CI)
    and even if I use mcr.microsoft.com/dotnet/sdk:5.0 which works correctly dotnet build commands executed in alpine fails with the same reason:

    Segmentation fault (core dumped)

    /home/build/.nuget/packages/gitversion.msbuild/5.6.6/tools/GitVersion.MsBuild.targets(9,9): error MSB3073: The command "dotnet --roll-forward Major "/home/build/.nuget/packages/gitversion.msbuild/5.6.6/tools/netcoreapp3.1/gitversion.dll" "/builds/ ... SOURCE_PATH" -output file -outputfile obj/gitversion.json" exited with code 139.

    Project has been configured to use dotnet 5.0.

  13. luis-fss commented on Mar 18, 2021

    @luis-fss

    @vadym fyi: this is my (now working) Dockerfile
    I emphasize that I am using GitVersion.MsBuild pinned in version 5.6.4 due to a bug in the version 5.6.5 and above.

    FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
    WORKDIR /src
    
    # copy files to container
    COPY *.sln .
    COPY nuget.config .
    COPY GitVersion.yml .
    COPY src/. ./src/
    COPY .git/ ./.git/
    
    # build and publish
    RUN dotnet restore
    RUN dotnet publish src/Presentation/PMCM/PMCM.csproj -c release -o /app --no-restore
    
    # final stage image
    FROM mcr.microsoft.com/dotnet/aspnet:5.0
    WORKDIR /app
    
    # install System.Drawing native dependencies
    # https://github.com/dotnet/dotnet-docker/blob/master/documentation/scenarios/using-system-drawing-common.md
    RUN apt-get update \ 
        && apt-get install -y --no-install-recommends --allow-unauthenticated \ 
            libc6-dev \ 
            libgdiplus \ 
            libx11-dev \ 
        && apt-get clean \ 
        && rm -rf /var/lib/apt/lists/*
    
    # Install fonts
    RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
    RUN apt-get update \ 
        && apt-get install -y --no-install-recommends ttf-mscorefonts-installer fontconfig \ 
        && apt-get clean \ 
        && rm -rf /var/lib/apt/lists/*
    RUN fc-cache -f -v
    
    COPY --from=build /app ./
    
    ARG APP_ENVIRONMENT='Development'
    ENV ASPNETCORE_ENVIRONMENT $APP_ENVIRONMENT
    ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED "true"
    ENTRYPOINT ["dotnet", "PMCM.dll"]
    
  14. vadym commented on Mar 18, 2021

    @vadym

    @Lukkian - Thank you for your proposal (to use debian). But I'd like to have solution without this vulnerability: https://security-tracker.debian.org/tracker/CVE-2019-25013.

  15. asbjornu commented on Mar 8, 2022

    @asbjornu
    Member

    I think this is resolved and can be closed. Please object if you disagree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions