Skip to content

dotnet trace ps running as root fails with System.IO.IOException: No such process : '/proc/2/environ' #6040

Description

@omajid

Description

I sometimes run dotnet trace as root (uid 0) under Linux. Recent versions of dotnet trace fail to run in this setup. Older versions of dotnet trace work fine.

# dotnet tool install -g dotnet-trace
You can invoke the tool using the following command: dotnet-trace
Tool 'dotnet-trace' (version '10.0.745401') was successfully installed.
# dotnet trace ps
System.IO.IOException: No such process : '/proc/2/environ'
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.File.ReadAllBytes(String path)
   at Microsoft.Diagnostics.NETCore.Client.PidIpcEndpoint.GetProcessTmpDir(Int32 hostPid, Boolean& environReadable) in /_/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcTransport.cs:line 437
   at Microsoft.Diagnostics.NETCore.Client.DiagnosticsClient.GetProcPublishedProcesses() in /_/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs:line 512
   at Microsoft.Diagnostics.NETCore.Client.DiagnosticsClient.GetPublishedProcesses() in /_/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs:line 420
   at Microsoft.Internal.Common.Commands.ProcessStatusCommandHandler.ProcessStatus(TextWriter stdOut, TextWriter stdError) in /_/src/Tools/Common/Commands/ProcessStatus.cs:line 123
# dotnet tool uninstall -g dotnet-trace
Tool 'dotnet-trace' (version '10.0.745401') was successfully uninstalled.
# dotnet tool install --global dotnet-trace --version 9.0.661903
You can invoke the tool using the following command: dotnet-trace
Tool 'dotnet-trace' (version '9.0.661903') was successfully installed.
# dotnet trace ps
 12419  dotnet  /usr/lib64/dotnet/dotnet  dotnet trace ps  

Configuration

  • Is this related to a specific tool? I see it in dotnet trace. It may nor may not affect other tools.
  • What OS and version, and what distro if applicable? Linux. Reproduced on Fedora 43 and 44.
  • What is the architecture (x64, x86, ARM, ARM64)? x64
  • Do you know whether it is specific to that configuration?
  • Are you running in any particular type of environment? root inside a VM.
  • Is it a self-contained published application? No application needed. dotnet trace ps by itself demostrates the problem.
  • What's the output of dotnet --info
# dotnet --info
.NET SDK:
 Version:           10.0.111
 Commit:            e2f47b0110
 Workload version:  10.0.100-manifests.330ea142
 MSBuild version:   18.0.11+e2f47b011

Runtime Environment:
 OS Name:     fedora
 OS Version:  43
 OS Platform: Linux
 RID:         fedora.43-x64
 Base Path:   /usr/lib64/dotnet/sdk/10.0.111/

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
  Version:      10.0.11
  Architecture: x64
  Commit:       e2f47b0110

.NET SDKs installed:
  10.0.111 [/usr/lib64/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 10.0.11 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 10.0.11 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_BUNDLE_EXTRACT_BASE_DIR           [/root/.cache/dotnet_bundle_extract]
  DOTNET_ROOT                              [/usr/lib64/dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

I also see this with 10.0.112

Regression?

Yes. 9.0.661903 worked.

Other information

  • Please include any relevant stack traces or error messages. If possible please include text as text rather than images (so it shows up in searches).
  • If you have an idea where the problem might lie, let us know that here. Please include any pointers to code, relevant changes, or related issues you know of.
  • Do you know of any workarounds? Don't run as root 😄

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions