diagnostics
diagnostics copied to clipboard
`dotnet-dump collect` silently fails if the user running the process does not have permission to write
$ dotnet-dump collect -p 736578
Writing full to /home/xpaw/core_20250211_130126
Complete
But in reality the file was not actually written, because the process I was dumping was running as another user (I ran the dump command as root) which didn't have permissions to write to my home folder. When I changed working directory to /tmp it actually worked.
The tool should report an error if it fails to actually write the file instead of saying complete.
I am using .NET 9.0.102 on Debian 12.
There's two issues:
- the IPC should have an error code.
- The errors are directed stream - it should have displayed on your side.
I am not able to reproduce this issue. What is the output of dotnet-dump --version?
It was 9.0.553101, highly unlikely that this was fixed in newer release.
Your working directory needs to be a path that the running process has no permission to.
I am still unable to reproduce the issue. I have your version of Debian, .NET, and dotnet-dump.
When I run dotnet-dump in a directory where the running process has rwx permissions, I receive the following success messages:
When I run it in a directory where the running process has rx permissions, I receive the following error messages:
Did you run dotnet-dump ps to find the appropriate PID? The PID that you wish to dump from must be listed here.
I don't know where the [createdump] messages are from, because I only see the "writing full to... complete" with the dump command.
The createdump messages are on the to-be-dumped process's side. Does your PID that you are attempting to dump appear in dotnet-dump ps?
I think that's kind of the point, if you run the dump command without actively reading the output of the running process, you can't see it fail.
That is not what I see on my end, if you look at the images you will see two images for the failure, one on the dotnet-dump side and one on the other process side.
I just tried it now. I don't see [createdump] logs on the collect side, I do see them on the process side, however there is no permission error being logged here either (despite the process not running as root)
[createdump] Gathering state for process xxx
[createdump] Writing full dump to file /root/.dotnet/tools/core_20250630_212037
[createdump] Target process is alive
And no dump was written. When I Ctrl-C'd the running process, it finally logged:
[createdump] Could not create output file '/root/.dotnet/tools/core_20250630_212037': Permission denied (13)
Could you try again with a dummy program that runs an infinite loop, with no debugger connected and running solely through dotnet run?
class Program
{
static void Main(string[] args)
{
while (true)
{
}
}
}
How do you run this program, for example is there a debugger attached?
The missing piece of information was that this only reproduces for PublishSingleFile builds.
dotnet publish -c release
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
single file:
$ ./bin/release/net9.0/linux-x64/publish/test
[createdump] Gathering state for process 3587386 test
[createdump] Writing full dump to file /root/.dotnet/tools/core_20250701_073539
[createdump] Target process is alive
^C
---
$ ./dotnet-dump collect -p 3587386
Writing full to /root/.dotnet/tools/core_20250701_073539
Complete
just self contained:
$ ./bin/release/net9.0/linux-x64/publish/test
[createdump] Gathering state for process 3588036 test
[createdump] Writing full dump to file /root/.dotnet/tools/core_20250701_073638
[createdump] Target process is alive
[createdump] Could not create output file '/root/.dotnet/tools/core_20250701_073638': Permission denied (13)
[createdump] Failure took 70ms
---
$ ./dotnet-dump collect -p 3588036
Writing full to /root/.dotnet/tools/core_20250701_073638
[createdump] Could not create output file '/root/.dotnet/tools/core_20250701_073638': Permission denied (13)
[createdump] Failure took 70ms
``
I am still unable to reproduce the issue. Could you please share your entire .csproj file?
I tested on a dotnet new console project, and added these two lines.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
Hello, This is an issue with how the runtime handles singlefile createdump requests. A fix has been initiated in the runtime repository.