Repository navigation
Description
Describe the Bug
While using aspnet:6.0.13-alpine3.17-amd64 as a baseimage and throwing an exception in program.cs, we got exit code 139 without any logging.
using aspnet:6.0.13-alpine3.16-amd64 shows thrown exception
Steps to Reproduce
- Create a ASPNET solution
- Add docker support
- Change base image to aspnet:6.0.13-alpine3.17-amd64
- Throw exception early in program.cs
- Start project using docker
- See that exception isnt thrown and docker container isnt showing anything
Example project https://github.com/TordS/TestBaseImageException.git
Output of docker version
Client:
Cloud integration: v1.0.29
Version: 20.10.21
API version: 1.41
Go version: go1.18.7
Git commit: baeda1f
Built: Tue Oct 25 18:08:16 2022
OS/Arch: windows/amd64
Context: default
Experimental: true
Server: Docker Desktop 4.14.1 (91661)
Engine:
Version: 20.10.21
API version: 1.41 (minimum version 1.12)
Go version: go1.18.7
Git commit: 3056208
Built: Tue Oct 25 18:00:19 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.9
GitCommit: 1c90a442489720eec95342e1789ee8a5e1b9536f
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Output of docker info
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.9.1)
compose: Docker Compose (Docker Inc., v2.12.2)
dev: Docker Dev Environments (Docker Inc., v0.0.3)
extension: Manages Docker extensions (Docker Inc., v0.2.13)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.21.0)
Server:
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 162
Server Version: 20.10.21
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
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: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 1c90a442489720eec95342e1789ee8a5e1b9536f
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 5.10.102.1-microsoft-standard-WSL2
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 5.795GiB
Name: docker-desktop
ID: 4CGJ:WD2F:RORI:I3M6:ZPJK:DSSE:YG7J:7EEL:E5OP:GKKN:JRSC:EX5N
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5000
127.0.0.0/8
Live Restore Enabled: false
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
mthalman commentedon Jan 26, 2023
Having the exception throw at this point in the program causes a segfault for some reason. I've attached a core dump: core.zip. Moving this issue to dotnet/runtime to investigate.
am11 commentedon Jan 26, 2023
This enables command line debugging in the repro container: am11/TestBaseImageException@39bea0a:
cc @janvorli
janvorli commentedon Jan 26, 2023
The issue is due to a problem unwinding out of the frame at the bottom of the stack above, the
ld-musl-x86_64.so.1 + -1. The libunwind unwinds from that frame to some unknown address and keeps going from there until it reaches an address that is in unmapped memory and so theVirtualCallStubManager::predictStubKindfails to read from that memory and the process exits with SIGSEGV.Stepping through the libunwind code, we reach the code path here:
runtime/src/coreclr/pal/src/libunwind/src/x86_64/Gstep.c
Lines 95 to 105 in 56c8497
That tries to fall back to frame chain unwinding (RBP chain in the x64 case). But there is no RBP chain there, so we walk through some bogus RBP ultimately reaching unreadable memory.
am11 commentedon Jan 26, 2023
A similar issue was fixed in libunwind/libunwind@b5cd210. We can try applying that patch?
I have a branch with libunwind 1.7.0-rc2 changes (https://github.com/am11/runtime/tree/feature/vendor/update-libunwind) waiting for 1.7 final cut before sending out the PR.
janvorli commentedon Jan 26, 2023
@am11 this is .NET 6.0 and it uses libunwind v1.5-rc1-28-g9165d2a1. I wonder if we should really go all the way to backporting 1.7.0. I am actually considering a surgical fix. We could possibly declare an exception unhandled if we reach the
coreclr_execute_assemblyorcoreclr_initialize. That would safe us from the issues of unwinding out of the bottom of the stack.am11 commentedon Jan 26, 2023
Sounds great. (I wasn't thinking about backporting the entire release 😅 just cherry-picking the commits which are already pushed to their main if possible)
janvorli commentedon Jan 26, 2023
FYI, the issue is with Alpine 3.17 only. I've tried it with the aspnet:6.0.13-alpine3.16-amd64 image and it worked correctly.
janvorli commentedon Jan 27, 2023
@am11 I've tried to cherry pick the change you've mentioned and it didn't fix the problem. I've also just found that the same issue happens in .NET 7.