Skip to content

dotnet-dump 0x80004005 on .NET 5 in Linux Docker container #2098

@mjrousos

Description

@mjrousos

Description

Running dotnet-dump in a Linux Docker container appears to always require SYS_PTRACE capability to collect dumps now and fails with 0x80004005 without it.

Regression?

Yes. Using dotnet-dump to collect dumps in Linux containers generally worked without any elevated privileges when running on .NET Core 3.1. On .NET 5, however, dump collection fails without SYS_PTRACE.

Other information

Repro steps:

  1. On a Win10 dev machine running Docker Desktop targeting Linux containers.
  2. Create a new .NET 5 ASP.NET Core WebAPI from a new-project template and add a Dockerfile with VS’s right-click “add Dockerfile” option.
  3. Build the Docker image
    1. docker build -t mjrousos/dockertest:latest -f Dockerfile ..
  4. Run the Docker container
    1. docker run -d --rm mjrousos/dockertest:latest
  5. Exec into the container
    1. docker exec -it f273 /bin/bash
  6. Install and run dotnet-dump
    1. apt-get update
    2. apt-get install curl
    3. curl -L https://aka.ms/dotnet-dump/linux-x64 -o dotnet-dump
    4. chmod +x ./dotnet-dump
    5. ./dotnet-dump ps
      1. 1 dotnet /usr/share/dotnet/dotnet
    6. ./dotnet-dump collect -p 1
      1. Writing full to /app/core_20210317_144707
      2. Writing dump failed (HRESULT: 0x80004005)

--Diag output looks good at first, but concludes with this error:

EnumerateElfInfo: phdr 0x5586152a5040 phnum 10
ERROR: ReadMemory(0x5586152a5040, 38) phdr FAILED

If I retarget my app and Dockerfile to netcoreapp3.1, though, the exact same steps work great and I get a dump

Repro code

I've pushed a sample solution to mjrousos/DockerDotnetDumpRepro. In its current state, dotnet-dump fails but after retargeting the csproj and Dockerfile to .NET Core 3.1, dotnet-dump succeeds. Also, a sample Docker image (targeting .NET 5) is available on Dockerhub as mjrousos/dockertest:latest.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions