microsoft / microsoft/ProcDump-for-Linux

Dump creation on exception fails for .NET-based systemd service running under a dedicated account

Open
#255 13 comments 0 reactions 1 assignee View on GitHub

@MarioHewardt is already working on this.

Since Aug 2, 2024.

feature request
Dominant language
C
Stars
3.1k
Forks
327
Avg merge
3d 10h
Merged PRs (30d)
7

Description

Expected behavior

Dump collected when OutOfMemoryException is thrown.

Actual behavior
[10:10:09 - DEBUG]: WaitForProfilerCompletion: Received status F in /__w/1/s/ProcDump-for-Linux/src/Monitor.cpp, at line 1928
[10:10:09 - DEBUG]: WaitForProfilerCompletion: Received dump length 0 in /__w/1/s/ProcDump-for-Linux/src/Monitor.cpp, at line 1932
[10:10:09 - DEBUG]: WaitForProfilerCompletion: Received dump path  in /__w/1/s/ProcDump-for-Linux/src/Monitor.cpp, at line 1959
[10:10:09 - ERROR]: Exception monitoring failed.
Steps to reproduce the behavior

Target process runs as a systemd service under a dedicated account, and I run the following command under my normal account:

sudo procdump -e -n 1 -f "OutOfMemoryException" -log stdout 5119 ~/dump
System information (e.g., distro, kernel version, etc.)
  • Ubuntu 22.04 on a virtual machine, no containers
  • .NET 8.0.7 from Microsoft repository
  • ProcDump 3.3.0
Additional information

Dumping works as expected on the same machine when I use a small test application, running it either as a normal process (without sudo), or as a systemd service under my user account.

Here is the relevant excerpt from journalctl log for the failing case:

Aug 02 10:10:09 <machine-name> <target-service-name>[12087]: [createdump] Target process is alive
Aug 02 10:10:09 <machine-name> <target-service-name>[5119]: [createdump] The process or container does not have permissions or access: open(/proc/5119/mem) FAILED Permission denied (13)
Aug 02 10:10:09 <machine-name> <target-service-name>[5119]: [createdump] Failure took 1ms

Looks like ProcDump loads one of its components into the target process and then tries to invoke createdump directly from there. AFAIK, createdump must be run with root priviledges, so I'm wondering why it works in other cases and only fails in this one.

Also, perhaps diagnostic can be improved, as it seems that exception monitoring works, but subsequent dump creation fails.

Please let me know if I can help by providing any additional information.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.