When attaching to an existing process as `root` the mkfifo permission for the non `root` process being monitored can not be written to due to a permission error. The easy thing I do in production is add `chmod a+w $pipe` just after the mkfifo, but this is messy. Instead perhaps we can inspect the owner of the process we are attaching to and maybe error out if we know we can not create that and add something like heaptrack -p PID --insecure-pipe , to workaround?
Hey Sam, that's an interesting bug report, thanks for pointing this limitation out to me - I certainly never ran into it yet :) I guess the right approach to fix it is indeed what you point out. First ensure that we attach with the right user, and if not then we should error out. Then using the `insecure-pipe` as a workaround would be a nice cherry on top to improve usability. Are you willing to provide a patch for that?
No problems Millan! I made https://github.com/KDE/heaptrack/pull/22 which is the simplest way I think we can work around it. I also noticed we are not cleaning up the pipe which probably does not matter, but may give us slightly cleaner detach behavior.
The pipe should be cleaned up via the trap, no? trap cleanup EXIT will call rm -f "$pipe" is that not working for you?
Yeah I do see the cleanup working, I think where I was getting confused is that I was doing a CTRL-C on heaptrack when it is attached and that left the file around, but I am not sure if there is any clean thing we can do for such a case.
Git commit 2d14f5de75b9dae33be0e782bcec043794e3f5e7 by Milian Wolff, on behalf of Sam Saffron. Committed on 15/10/2019 at 21:06. Pushed by mwolff into branch 'master'. Allow high priv user to profile low priv user process In some cases `root` may attach to a non `root` process, in that case we need to ensure th pipe can be written to by the process being profiled M +10 -0 src/track/heaptrack.sh.cmake https://commits.kde.org/heaptrack/2d14f5de75b9dae33be0e782bcec043794e3f5e7