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

build.sh causes segfault on Alpine Linux just after running Darc #1868

Closed
PureTryOut opened this issue Nov 9, 2020 · 19 comments
Closed

build.sh causes segfault on Alpine Linux just after running Darc #1868

PureTryOut opened this issue Nov 9, 2020 · 19 comments

Comments

@PureTryOut
Copy link

PureTryOut commented Nov 9, 2020

I'm trying to compile dotnet from source but somewhere in the build.sh process just after running Darc the dotnet executable segfaults. Note that even though it says it could not find zlib, zlib-dev is installed.

Initialized empty Git repository in /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.git/
Found bootstrap SDK 3.1.109, bootstrap Arcade 1.0.0-beta.19359.6
+++ dirname ./build.sh
++ cd -P .
++ pwd
+ scriptroot=/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0
+ '[' false == true ']'
++ date +%m%d%H%M%S
+ /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/eng/common/build.sh --restore --build -c Release --warnaserror false /bl:/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/artifacts/log/Debug/Build_1109114237.binlog /flp:v=diag
Downloading 'https://dot.net/v1/dotnet-install.sh'
wget: server returned error: HTTP/1.1 404 Not Found
wget: server returned error: HTTP/1.1 404 Not Found
dotnet_install: Warning: Unable to locate zlib. Probable prerequisite missing; install zlib.
dotnet-install: Downloading link: https://dotnetcli.azureedge.net/dotnet/Sdk/3.1.109/dotnet-sdk-3.1.109-linux-musl-x64.tar.gz
dotnet-install: Extracting zip from https://dotnetcli.azureedge.net/dotnet/Sdk/3.1.109/dotnet-sdk-3.1.109-linux-musl-x64.tar.gz
dotnet-install: Adding to current process PATH: `/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.dotnet`. Note: This change will be visible only when sourcing script.
dotnet-install: Installation finished successfully.

Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.109

----------------
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Write your first app: https://aka.ms/first-net-core-app
--------------------------------------------------------------------------------------
/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.dotnet/sdk/3.1.109/MSBuild.dll /nologo -maxcpucount /m -verbosity:m /v:minimal /bl:/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/artifacts/log/Debug/Build_1109114237.binlog /clp:Summary /flp:v=diag /nr:true /p:TreatWarningsAsErrors=false /p:ContinuousIntegrationBuild=false /p:Configuration=Release /p:RepoRoot=/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0 /p:Restore=true /p:Build=true /p:Rebuild=false /p:Test=false /p:Pack=false /p:IntegrationTest=false /p:PerformanceTest=false /p:Sign=false /p:Publish=false /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/packages/restored/microsoft.dotnet.arcade.sdk/1.0.0-beta.19359.6/tools/Build.proj
/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/packages/restored/microsoft.dotnet.arcade.sdk/1.0.0-beta.19359.6/tools/ProjectLayout.props(8,3): warning MSB4011: "/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/packages/restored/microsoft.dotnet.arcade.sdk/1.0.0-beta.19359.6/tools/RepoLayout.props" cannot be imported again. It was already imported at "/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/packages/restored/microsoft.dotnet.arcade.sdk/1.0.0-beta.19359.6/tools/Build.proj (52,3)". This is most likely a build authoring error. This subsequent import will be ignored.                                                  
  Restore completed in 2.37 sec for /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/packages/restored/microsoft.dotnet.arcade.sdk/1.0.0-beta.19359.6/tools/Tools.proj.
  Restore completed in 1.1 sec for /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/build.proj.
  Restore completed in 11.8 sec for /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/Microsoft.DotNet.SourceBuild.Tasks.XPlat.csproj.
  Restore completed in 120.55 ms for /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/tools-local/tasks/SourceBuild.MSBuildSdkResolver/SourceBuild.MSBuildSdkResolver.csproj.
  Microsoft.DotNet.SourceBuild.Tasks.XPlat -> /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/tools-local/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/bin/Release/Microsoft.DotNet.SourceBuild.Tasks.XPlat.dll
  SourceBuild.MSBuildSdkResolver -> /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/artifacts/x64/Release/SourceBuild.MSBuildSdkResolver.dll
  Adding resolver to SDK: SourceBuild.MSBuildSdkResolver -> /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.dotnet/sdk/3.1.109/SdkResolvers/SourceBuild.MSBuildSdkResolver/SourceBuild.MSBuildSdkResolver.dll
  [11:44:11.03] Installing Darc.
  Tool path '/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.dotnet/tools/' does not exist.
  Installing Darc CLI version 1.1.0-beta.19568.2...
  You may need to restart your command shell if this is the first dotnet tool you have installed.
  Restore completed in 14.08 sec. You can invoke the tool using the following command: darc
   Tool 'microsoft.dotnet.darc' (version '1.1.0-beta.19568.2') was successfully installed.
  [11:44:27.13] Done installing Darc.
  [11:44:27.14] Getting source code for repos in Version.Details.xml.
  [11:44:27.14] Running Darc command: '/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.dotnet/dotnet /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/Microsoft.DotNet.Darc.dll clone  --git-dir-folder /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.git/modules/src/ --include-toolset --ignore-repos ";https://dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted;https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted;https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://github.com/dotnet/source-build-reference-packages" --debug --azdev-pat bogus --github-pat bogus --depth 0' from working dir /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/
  info: Microsoft.DotNet.Darc.Operations.Operation[0]
        Getting a collection of dependencies from 'eng/Version.Details.xml' in repo '/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0'...
  info: Microsoft.DotNet.Darc.Operations.Operation[0]
        Reading 'eng/Version.Details.xml' in repo '/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0' and branch ''...
  info: Microsoft.DotNet.Darc.Operations.Operation[0]
        Reading 'eng/Version.Details.xml' from repo '/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0' and branch '' succeeded!
  dbug: Microsoft.DotNet.Darc.Operations.Operation[0]
        Skipping ignored repo https://github.com/dotnet/source-build-reference-packages (at e25d677d8963a6fb3156adf21d4c3a80738aecf4)
  info: Microsoft.DotNet.Darc.Operations.Operation[0]
        Found 29 local dependencies.  Starting deep clone...
  dbug: Microsoft.DotNet.Darc.Operations.Operation[0]
        Starting master copy for https://github.com/dotnet/arcade in /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/artifacts/src/arcade with .gitdir /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.git/modules/src/arcade.git
  dbug: Microsoft.DotNet.Darc.Operations.Operation[0]
        Master .gitdir /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.git/modules/src/arcade.git does not exist
  info: Microsoft.DotNet.Darc.Operations.Operation[0]
        Cloning master copy of https://github.com/dotnet/arcade into /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/artifacts/src/arcade with .gitdir path /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.git/modules/src/arcade.git
  dbug: Microsoft.DotNet.Darc.Operations.Operation[0]
        Cloning https://github.com/dotnet/arcade to /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/artifacts/src/arcade
  Segmentation fault
/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/tools-local/init-build.proj(204,5): error MSB3073: The command "/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.dotnet/dotnet /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/Microsoft.DotNet.Darc.dll clone  --git-dir-folder /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.git/modules/src/ --include-toolset --ignore-repos ";https://dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted;https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted;https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://github.com/dotnet/source-build-reference-packages" --debug --azdev-pat bogus --github-pat bogus --depth 0 --repos-folder /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/artifacts/src/" exited with code 139.

Build FAILED.

/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/packages/restored/microsoft.dotnet.arcade.sdk/1.0.0-beta.19359.6/tools/ProjectLayout.props(8,3): warning MSB4011: "/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/packages/restored/microsoft.dotnet.arcade.sdk/1.0.0-beta.19359.6/tools/RepoLayout.props" cannot be imported again. It was already imported at "/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/packages/restored/microsoft.dotnet.arcade.sdk/1.0.0-beta.19359.6/tools/Build.proj (52,3)". This is most likely a build authoring error. This subsequent import will be ignored. 
/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/tools-local/init-build.proj(204,5): error MSB3073: The command "/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.dotnet/dotnet /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/Microsoft.DotNet.Darc.dll clone  --git-dir-folder /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.git/modules/src/ --include-toolset --ignore-repos ";https://dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted;https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted;https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://github.com/dotnet/source-build-reference-packages" --debug --azdev-pat bogus --github-pat bogus --depth 0 --repos-folder /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/artifacts/src/" exited with code 139.
    1 Warning(s)
    1 Error(s)

Time Elapsed 00:00:36.06
Build failed (exit code '1').
@dagood
Copy link
Member

dagood commented Nov 9, 2020

darc would output a lot more lines than that if it had completed--the segfault happened during the darc command. Try running it again based on the log and see if it repros:

cd /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/
/home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.dotnet/dotnet /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/Microsoft.DotNet.Darc.dll clone  --git-dir-folder /home/bart/Documents/Git/alpine/aports/testing/dotnet/src/source-build-2b1abb23997ef7cd23182455e0c6566e205e43d0/.git/modules/src/ --include-toolset --ignore-repos ";https://dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted;https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted;https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://github.com/dotnet/source-build-reference-packages" --debug --azdev-pat bogus --github-pat bogus --depth 0

If you're familiar with how to run it in a debugger, get a memory dump, that kind of thing, that would be good to be able to report the bug to dotnet/arcade (where Darc is maintained) or dotnet/runtime (if it's an underlying Runtime bug with linux-musl-x64).

We don't have CI running for linux-musl-x64 on dotnet/source-build, so I'm not sure this will work all the way through even once you get darc working. Not to say we won't try to help along the way, but I just don't know the current state.

We have run into a segfault due to not having enough memory, although elsewhere in the build: #1687. It might be useful if you could give some machine info.

@PureTryOut
Copy link
Author

Not sure how to get a memory dump, but normally I'm able to get a backtrace with gdb and all that. dotnet seems to react a bit different to the usual Linux programs however...

> 
gdb $PWD/.dotnet/dotnet --args $PWD/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/Microsoft.DotNet.Darc.dll clone --git-dir-folder $PWD/.git/modules/src/ --include-toolset --ignore-repos ";https://dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted;https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted;https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://github.com/dotnet/source-build-reference-packages" --debug --azdev-pat bogus --github-pat bogus --depth 0
GNU gdb (GDB) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/bart/Documents/Git/source-build/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/Microsoft.DotNet.Darc.dll...
(No debugging symbols found in /home/bart/Documents/Git/source-build/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/Microsoft.DotNet.Darc.dll)
(gdb) r
Starting program: /home/bart/Documents/Git/source-build/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/Microsoft.DotNet.Darc.dll clone --git-dir-folder /home/bart/Documents/Git/source-build/.git/modules/src/ --include-toolset --ignore-repos \;https://dev.azure.com/dnceng/internal/_git/dotnet-optimization\;https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted\;https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted\;https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-optimization\;https://github.com/dotnet/source-build-reference-packages --debug --azdev-pat bogus --github-pat bogus --depth 0
Failed to execute process '/home/bart/Documents/Git/source-build/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/Microsoft.DotNet.Darc.dll'. Reason:
exec: unknown error (errno was 8)
The file '/home/bart/Documents/Git/source-build/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/Microsoft.DotNet.Darc.dll' is marked as an executable but could not be run by the operating system.
During startup program exited with code 125.

(this was the failing command)

I doubt it's a lack of memory, this system has 32GB's of it 😉 Also running on a R7 1700.

> cat /etc/os-release 
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.13.0_alpha20200917
PRETTY_NAME="Alpine Linux edge"

@omajid
Copy link
Member

omajid commented Nov 9, 2020

I think there's a mistake here:

gdb $PWD/.dotnet/dotnet --args $PWD/.dotnet/tools/.store/microsoft.dotnet.darc/...

The --args argument should come first, and the program name after that:

gdb --args $PWD/.dotnet/dotnet $PWD/.dotnet/tools/.store/microsoft.dotnet.darc/...

@PureTryOut
Copy link
Author

That... Is not what I expected and totally true.

The backtrace doesn't seem that useful to me but hopefully you disagree.

(gdb) bt
#0  0x0000000000014c86 in ?? ()
#1  0x00007ffff1d766a9 in stdalloc.strdup ()
   from /home/bart/Documents/Git/source-build/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/runtimes/debian.9-x64/native/libgit2-7ce88e6.so
#2  0x00007ffff1d0f8b0 in filter_registry_insert ()
   from /home/bart/Documents/Git/source-build/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/runtimes/debian.9-x64/native/libgit2-7ce88e6.so
#3  0x00007ffff1d0fad0 in git_filter_global_init ()
   from /home/bart/Documents/Git/source-build/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/runtimes/debian.9-x64/native/libgit2-7ce88e6.so
#4  0x00007ffff1d11ba2 in init_once ()
   from /home/bart/Documents/Git/source-build/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/runtimes/debian.9-x64/native/libgit2-7ce88e6.so
#5  0x00007ffff7fbaf0f in ?? () from /lib/ld-musl-x86_64.so.1
#6  0x0000000000000000 in ?? ()

strace.txt

@omajid
Copy link
Member

omajid commented Nov 9, 2020

It looks like this libgit is being used:

/home/bart/Documents/Git/source-build/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/runtimes/debian.9-x64/native/libgit2-7ce88e6.so

And based on the name here (debian.9-x64), it was linked against glibc and doesn't support musl.

There should be a alpine-x64/native/libgit2-7ce88e6.so; I wonder why that's not getting used.

As a hack, what happens if you delete everything under /home/bart/Documents/Git/source-build/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/runtimes/ that's not alpine-x64?

@PureTryOut
Copy link
Author

> $PWD/.dotnet/dotnet $PWD/.dotnet/tools/.store/microsoft.dotnet.darc/1.1.0-beta.19568.2/microsoft.dotnet.darc/1.1.0-beta.19568.2/tools/netcoreapp3.0/any/Microsoft.DotNet.Darc.dll clone --git-dir-folder $PWD/.git/modules/src/ --include-toolset --ignore-repos ";https://dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://dev.azure.com/devdiv/DevDiv/_git/DotNet-Trusted;https://devdiv.visualstudio.com/DevDiv/_git/DotNet-Trusted;https://dnceng@dev.azure.com/dnceng/internal/_git/dotnet-optimization;https://github.com/dotnet/source-build-reference-packages" --debug --azdev-pat bogus --github-pat bogus --depth 0
Error:
  An assembly specified in the application dependencies manifest (Microsoft.DotNet.Darc.deps.json) was not found:
    package: 'System.Data.SqlClient', version: '4.4.2'
    path: 'runtimes/unix/lib/netstandard2.0/System.Data.SqlClient.dll'

@omajid
Copy link
Member

omajid commented Nov 9, 2020

Doh, I asked for unix to be removed and that doesn't work (obviously). Okay, how about trying again and keeping all alpine variants, unix and linux-x64?

@dagood
Copy link
Member

dagood commented Nov 9, 2020

I would expect dotnet (or something else related to hosting .NET executables?) to find the right copy to use based on this list in Microsoft.DotNet.Darc.deps.json (plus .dotnet/sdk/5.0.100-rc.1.20452.10/RuntimeIdentifierGraph.json for RID graph lookup I think):

...
      "LibGit2Sharp.NativeBinaries/2.0.289": {
        "runtimeTargets": {
          "runtimes/alpine-x64/native/libgit2-7ce88e6.so": {
            "rid": "alpine-x64",
            "assetType": "native",
            "fileVersion": "0.0.0.0"
          },
...
          "runtimes/debian.9-x64/native/libgit2-7ce88e6.so": {
            "rid": "debian.9-x64",
            "assetType": "native",
            "fileVersion": "0.0.0.0"
          },
...

I noticed that your os-release is for Alpine 3.13.0_alpha20200917. I'm not sure if this would be a RID of alpine.3.13-x64 or alpine.3.13.0_alpha20200917-x64... @PureTryOut could you run .dotnet/dotnet --info to check what it calculates?

I see in my RuntimeIdentifierGraph.json that the entries only go up to alpine.3.12-x64, so it could be that it's failing to detect anything at all and falling back to something that it thinks will work, that in this case doesn't.

@PureTryOut
Copy link
Author

Keeping the linux-x64 and unix runtimes does indeed work.

I'm guessing the scripts will work on any stable version but not on edge then, which has a moving version number (current latest stable + 1 basically).

> .dotnet/dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.109
 Commit:    32ced2d411

Runtime Environment:
 OS Name:     alpine
 OS Version:  3.13
 OS Platform: Linux
 RID:         linux-musl-x64
 Base Path:   /home/bart/Documents/Git/dotnet/.dotnet/sdk/3.1.109/

Host (useful for support):
  Version: 3.1.9
  Commit:  774fc3d6a9

.NET Core SDKs installed:
  3.1.109 [/home/bart/Documents/Git/dotnet/.dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.9 [/home/bart/Documents/Git/dotnet/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.9 [/home/bart/Documents/Git/dotnet/.dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

@dagood
Copy link
Member

dagood commented Nov 9, 2020

It's not the scripts so much as the .NET SDK itself in this case--but yeah, problems come up with "unknown" RIDs like this. New versions of distros tend to be added to the RID graph as they come alive and get .NET support, although sometimes new distro versions are added ahead of time too.

I vaguely remember an issue in dotnet/runtime proposing that the RID graph shouldn't be as static (and should allow for higher than expected versions) but can't find it.

On the dotnet/source-build side, we do want to go further to support arbitrary RIDs, tracked by #297. This would help with newer-than-expected RIDs and also for distros that will never be "official" in dotnet/runtime's RuntimeIdentifierGraph.json.

@PureTryOut
Copy link
Author

Is there an available workaround for now that doesn't involve letting build.sh fail first to then manually remove the runtimes? I'm trying to turn this into a package for the Alpine Linux repositories and this is not a valid approach to get it working there 😉

Also, build.sh continues now but fails again later on while compiling libunwind it seems:

[  1%] Building C object src/pal/src/libunwind/src/CMakeFiles/libunwind.dir/os-linux.c.o
  In file included from /home/bart/Documents/Git/dotnet/artifacts/src/coreclr.d989459717cbce34262060c4b8b949185033e379/src/pal/src/misc/tracepointprovider.cpp:19:
  In file included from /home/bart/Documents/Git/dotnet/artifacts/src/coreclr.d989459717cbce34262060c4b8b949185033e379/src/pal/src/include/pal/palinternal.h:620:
  In file included from /usr/bin/../lib/gcc/x86_64-alpine-linux-musl/10.2.0/../../../../include/c++/10.2.0/stdlib.h:30:
  /usr/include/stdlib.h:23:11: error: 'atoll' is missing exception specification 'throw()'
  long long atoll (const char *);
            ^
  /home/bart/Documents/Git/dotnet/artifacts/src/coreclr.d989459717cbce34262060c4b8b949185033e379/src/pal/inc/pal.h:4224:33: note: previous declaration is here
  PALIMPORT long long int __cdecl atoll(const char *) THROW_DECL;
                                  ^

A version of libunwind (1.4.) however is available in the Alpine repositories, is it possible to make it use that?

@omajid
Copy link
Member

omajid commented Nov 9, 2020

Is there an available workaround for now that doesn't involve letting build.sh fail first to then manually remove the runtimes?

I dont know of one.

We fixed something like this before via libgit2/libgit2sharp#1714 but maybe it doesn't handle alpine too well?

Also, build.sh continues now but fails again later on while compiling libunwind it seems:

I think the build output is confusing. It's probably not related to libunwind. It reminds me of dotnet/coreclr#28045, but that was only needed for 2.1. I wonder why/how you are getting this. What version of clang is this?

A version of libunwind (1.4.) however is available in the Alpine repositories, is it possible to make it use that?

Yes. I doubt it will fix your problem, but you can pass -p:UseSystemLibunwind=true to build.sh:

./build.sh -p:UseSystemLibunwind=true

@PureTryOut
Copy link
Author

You're right, libunwind from the system doesn't help, but it being possible does help the chances of this package eventually being accepted to Alpine. Is there somewhere I can read up on these build arguments?

I'm using Clang 10.0.1.

@dagood
Copy link
Member

dagood commented Nov 9, 2020

Is there an available workaround for now that doesn't involve letting build.sh fail first to then manually remove the runtimes?

You could add a patch to the Alpine build that inserts the rm(s) you need just before the closing } here:

echo "You may need to restart your command shell if this is the first dotnet tool you have installed."
if [ -z "$toolpath" ]; then
echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity -g)
else
echo $($dotnet_root/dotnet tool install $darc_cli_package_name --version $darcVersion --add-source "$arcadeServicesSource" -v $verbosity --tool-path "$toolpath")
fi
}

(We call that from https://github.com/dotnet/source-build/blob/release/3.1/tools-local/acquire-darc/acquire-darc.proj#L5. A patch there would also be reasonable, but not sure if you're familiar with MSBuild code. The darc-init.sh file itself is maintained at https://github.com/dotnet/arcade/blob/master/eng/common/darc-init.sh, we just have a copy in the repo.)

We fixed something like this before via libgit2/libgit2sharp#1714 but maybe it doesn't handle alpine too well?

This might be beyond a reasonable fix in libgit2sharp--it seems to me they would have to implement their own RID tree to be able to do better than they do now, which seems possible, but it's not something I'd be eager to maintain in their shoes when .NET should do this for me. 😄

It seems to me the "try a few sos to see what loads properly" feature in that PR is actually able to load the Debian so fine, but then when it tries to execute a (particular?) Git command, it hits a segmentation fault. Not sure if it can be handled gracefully at that point. (Unload, load another so, and retry the current operation?)

Is there somewhere I can read up on these build arguments?

-p:Foo=Bar (aka /p:Foo=bar) sets a global property in MSBuild, so there's no central place that handles these--it's up to raw understanding of the source-build infra, or docs, which are pretty limited right now in source-build.

I think it would make sense to describe how using system libraries works at https://github.com/dotnet/source-build/blob/release/3.1/Documentation/packaging-installation.md at some point since it's particularly important when building for a distro.

@dagood
Copy link
Member

dagood commented Nov 9, 2020

The fix that I imagine we'd do at some point in the future in source-build would be either:

  • Stop using darc, instead build our own managed build task that doesn't use a native dependency. (Use git via process exec.)
  • Accept build arguments that our build infra uses to patch up .dotnet/.../RuntimeIdentifierGraph.json before running darc.
    • We have to accept this kind of arg for Add support for banana linux #297, so while that issue technically tracks something slightly different (IMO), it's very tightly related.

@PureTryOut
Copy link
Author

PureTryOut commented Nov 9, 2020

You could add a patch to the Alpine build that inserts the rm(s) you need just before the closing }

That does the trick yes, thanks.

A patch there would also be reasonable, but not sure if you're familiar with MSBuild code.

I'm not sorry, this is my first time looking into this whole ordeal.

I think it would make sense to describe how using system libraries works at https://github.com/dotnet/source-build/blob/release/3.1/Documentation/packaging-installation.md at some point since it's particularly important when building for a distro.

Yes please, also, including instructions on how to do a complete offline build would be nice.

@dagood
Copy link
Member

dagood commented Nov 9, 2020

I guess I didn't quite link to the right doc for that. There are actually instructions for how to do an offline build here (and notes for how to use system libraries would go somewhere around there I guess): https://github.com/dotnet/source-build/tree/release/3.1/Documentation#building-net-core-sdk-and-a-source-tarball

@PureTryOut
Copy link
Author

I'm splitting off the coreclr build failure and request to document flags for using system libraries rather than internal ones.

@dagood
Copy link
Member

dagood commented Nov 19, 2020

I think everything here is tracked elsewhere now:

Let me know if there's something I missed! Thanks for filing those separate followup issues.

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

3 participants