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

Segmentation fault in 3.1 docker image #2308

Closed
mabead opened this issue Jun 1, 2020 · 15 comments
Closed

Segmentation fault in 3.1 docker image #2308

mabead opened this issue Jun 1, 2020 · 15 comments
Labels

Comments

@mabead
Copy link

mabead commented Jun 1, 2020

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
@mabead mabead added the bug label Jun 1, 2020
@asbjornu
Copy link
Member

asbjornu commented Jun 2, 2020

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

@mabead
Copy link
Author

mabead commented Jun 2, 2020

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.

@asbjornu
Copy link
Member

asbjornu commented Jun 2, 2020

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.

@mabead
Copy link
Author

mabead commented Jun 2, 2020

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.

@asbjornu
Copy link
Member

asbjornu commented Jun 2, 2020

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.

@mabead
Copy link
Author

mabead commented Jun 2, 2020

@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 ;)

@asbjornu
Copy link
Member

asbjornu commented Jun 2, 2020

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

image

@dejoost
Copy link

dejoost commented Nov 17, 2020

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

@luis-fss
Copy link

luis-fss commented Feb 9, 2021

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

@asbjornu
Copy link
Member

asbjornu commented Feb 9, 2021

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

@luis-fss
Copy link

luis-fss commented Feb 9, 2021

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)

@vadym
Copy link

vadym commented Mar 18, 2021

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.

@luis-fss
Copy link

@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"]

@vadym
Copy link

vadym commented Mar 18, 2021

@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.

@asbjornu
Copy link
Member

asbjornu commented Mar 8, 2022

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

@asbjornu asbjornu closed this as completed Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants