Error attaching to process in Linux

I am trying to attach to a self-contained .NET 5 process using this command: ./dottrace attach 130121

I receive the following error message:
Can't attach to invalid handle [location] = /opt/buildAgent/work/bb1ab4feb0b2de6d/Profiler/Kernel/Windows/Native/Solution/core/src/Stream/FileNativeStream.cpp(55) [function] = void FileNativeStream::Attach(jb::file_handle &&, const jb::file_access)
Unable to start profiling. Profiler attach failed (HRESULT: 0x80004005).

The same thing happens if I run dottrace with sudo. If I try to start the process using dottrace it does work, but I need to be able to attach to a running process. Any help would be appreciated.

0
4 comments

Hi,

I'm sorry for the delay with the answer.

Is this issue still actual for you? If yes, what Linux distributive are you using?

0

We have same issue, using mcr.microsoft.com/dotnet/runtime-deps:5.0-buster-slim-amd64 image and netcoreapp3.1 or net5.0 application.

 

This issue makes impossible for us to use dottrace tool inside linux docker containers.

 

0

Hello,

We've checked running dottrace tool with runtime-deps:5.0-buster-slim-amd64 and it works properly in our environment.

Here is the steps which were performed:

1. Run docker:

sudo docker run -it mcr.microsoft.com/dotnet/runtime-deps:5.0-buster-slim-amd64

2. Download dotTrace clt:

apt update
apt install procps wget
wget https://download.jetbrains.com/resharper/dotUltimate.2021.2.2/JetBrains.dotTrace.CommandLineTools.linux-x64.2021.2.2.tar.gz

3. Unzip clt to the new folder in /root

cd /root
mkdir dottraceclt
cd ./dottraceclt
tar -zxvf /root/JetBrains.dotTrace.CommandLineTools.linux-x64.2021.2.2.tar.gz

4. Copy and run .net 5.0 console app in the second console instance (sudo docker exec -it ID /bin/bash)

5. Get process pid (ps -aux) and attach to it from the first console instance via ./dottrace attach <PID>:

root@d37bc2c0c784:~/dottraceclt# ./dottrace attach 387
dotTrace command-line profiler 2021.2.2 build 777.0.20211001.131124. Copyright (C) 2021 JetBrains s.r.o.
Profiling in progress...
Profiling is finished in 273.463 seconds
Collected snapshot: /root/dottraceclt/Dadoqep.dtp

Profiler attaches properly and snapshot is saved when app finishes.

"Unable to start profiling. Profiler attach failed (HRESULT: 0x80004005)" error may occur when dottrace and your application is started under different accounts. Currently, dottrace doesn't support cross-user profiling on Linux.

Could you please describe your use case in detail? Maybe you are doing something differently.

0

Thank you! It is really works under the same user.

Previously we used `nsenter` instead of `docker exec`.

0

Please sign in to leave a comment.