efcore: Alpine 3.13 image is crashing on dotnet test
Describe the Bug
Running dotnet test on Alpine 3.13 docker based image crashes test runner.
When running on mcr.microsoft.com/dotnet/sdk:5.0-alpine3.12 it succeeds When running on mcr.microsoft.com/dotnet/sdk:5.0-alpine it fails
Steps to Reproduce
Dockerized repro based on https://github.com/dotnet/EntityFramework.Docs (https://github.com/dotnet/EntityFramework.Docs/tree/master/samples/core/Miscellaneous/Testing/ItemsWebApi/Tests specifically)
Start docker sdk alpine image
docker run -it --rm mcr.microsoft.com/dotnet/sdk:5.0-alpine
and then. execute this in interactive terminal…
#working project dir
cd /srv/
#I just need proper ll, c'mon
alias ll='ls -lah --color'
#usefull debugging and testing stuff
apk add --update vim strace gdb
#our repo to reproduce
git clone https://github.com/dotnet/EntityFramework.Docs.git
#working dir with tests
cd /srv//EntityFramework.Docs/samples/core/Miscellaneous/Testing/ItemsWebApi/Tests/
#build for restoring packages, simple.
dotnet build
#now tests - this crashes!!!!
dotnet test
#deeper investigation?
#strace dotnet test --logger trx --results-directory _temp -v m --blame-crash
#vim -p _temp/*.trx _temp/*/*.xml
Other Information
The same stuff when run with docker run -it --rm mcr.microsoft.com/dotnet/sdk:5.0-alpine works and just properly fails saying LocalDB is not avaialblre under Linux 😃
Output of docker version
Client:
Version: 19.03.15
API version: 1.40
Go version: go1.15.7
Git commit: 420b1d3625
Built: Thu Feb 4 20:43:34 2021
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 19.03.15
API version: 1.40 (minimum version 1.12)
Go version: go1.15.7
Git commit: 420b1d3625
Built: Thu Feb 4 20:43:19 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.3.9
GitCommit: ea765ab
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683b971d9c3ef73f284f176672c44b448662
Output of docker info
Client:
Debug Mode: false
Server:
Containers: 2
Running: 2
Paused: 0
Stopped: 0
Images: 40
Server Version: 19.03.15
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: ea765ab
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683b971d9c3ef73f284f176672c44b448662
Security Options:
seccomp
Profile: default
Kernel Version: 5.4.72-gentoo
Operating System: Gentoo/Linux
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 31.29GiB
Name: chaos2
ID: OUE5:YKZ7:KCDZ:CTG3:BDT2:KLUH:7BW4:FRYG:47XX:25NZ:F5AL:Y67R
Docker Root Dir: /mnt/samsung512GB/var/lib/docker
Debug Mode: false
Username: chaosengine
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 39 (21 by maintainers)
Commits related to this issue
- Fix sqlite Segmentation Fault https://github.com/dotnet/efcore/issues/24189 — committed to chneau/example-todo-aspnet-react by chneau 3 years ago
I’ve confirmed it’s a segfault crash. It occurs when calling
context.Database.EnsureCreated()when using a file-based connection for SQLite. So it seems to be related to Entity Framework or native implementation of SQLite. I saw that the db file does get created on the file system.I’ve created a simple repro project that doesn’t involve
dotnet test. The crux of the repro is here:The call to
EnsureCreatedis what causes the crash.Repro steps
docker build -t app .docker run --rm -it appI’ve also collected a crash dump: core.zip
Let’s move this discussion to https://github.com/dotnet/runtime/issues/50739. Let’s make that a servicing issue and address it in the next release.
Based on what I saw above, it looks like everything succeeded with Alpine docker image 3.12 and then failed with 3.13. So I had been assuming something changed in between that caused the break.
One possibility I have not investigated yet is that maybe “the thing that changed” would require me to build the alpine sqlite library differently, such as, for example, with a more recent compiler or C lib, etc.
I’ll try the repro above and see if it yields any clues.
Great investigative work, @ChaosEngine. Definitely looks related to the rid.
It’s strange because I’ve confirmed that alpine.3.13 is defined as an available rid:
Adding @wfurt who added this rid to see if he has an idea here. @wfurt , take a look at the output shown here: https://github.com/dotnet/efcore/issues/24189#issuecomment-798542743. Why would
dotnet --infoprint outlinux-musl-x64for the rid on Alpine 3.13 while it prints outalpine.3.12-x64on Alpine 3.12?It seems to be the same as reported here: https://github.com/dotnet/runtime/issues/28303#issuecomment-646994218
RID: linux-musl-x64RID: alpine.3.12-x64and this could be the imain issue here, app assembly not linking to proper native SQLite runtime???I think this proves it. I run built app (
/app/bin/Debug/net5.0/app) in gdb and force a crash, than showed loaded shared libraries.loading
/app/bin/Debug/net5.0/runtimes/linux-x64/native/libe_sqlite3.soWhile doing the compilation I noticed something interesting. When added runtime suffix for alpine (
-r alpine-x64)the repro.zip case worked:also my original repro from the docs works with test project when run with
dotnet test -v m --runtime alpine-x64Is it possible that default dotnet runtime on alpine3.13 is not detected properly somehow? Digging deeper into this…🧐
Ok, looks like a homework for me 😃 Will try to give this a shot during weekend (lockdown on my side so what else).
You could try these instructions to upgrade your WSL Alpine installation to 3.13. And here are instructions for for installing gcc on Alpine.
OK, I haven’t gotten anywhere on this.
I have no experience with alpine linux, and very little experience with docker. I want to learn these things, but having my education in the critical path of this issue may not be a good idea.
I assume that if I just build sqlite on alpine 3.13 the resulting library would work.
Anybody want to give me just enough docker knowledge to run gcc under alpine 3.13 ?
I have wsl 2 installed, which I use regularly, but I don’t see a wsl image for alpine 3.13 yet.
Feel free to just tell me to go back and do my homework, but if you want to move this bug along, telling me exactly what commands to type would probably do that. 😃
I’m going to try and get setup to build an e_sqlite3 actually under alpine 3.13.