gh-149619: Fix _remote_debugging permissions error on Linux#150012
Conversation
_remote_debugging permissions error on Linux
c82242b to
31c5119
Compare
When running profiling on Linux without sudo, attempts to read process memory would fail with the misleading error 'Failed to find the PyRuntime section in process <pid> on Linux platform'. The actual issue is a permissions error because profiling was not run with sudo. We were clearing the exception on Linux when trying to read memory, instead, we should bubble up the permissions error and show it properly.
31c5119 to
2471dee
Compare
|
cc @maurycy |
There was a problem hiding this comment.
I cannot click "Approve" but it's great. 🎉 The issue is gone. 🌬️
Two side comments!
My hunch is that there's still something subtle around error propagation (likely: EACCES propagation) but I cannot catch any!
I spent some time thinking on how to test it. What do you think about:
@unittest.skipUnless(
sys.platform == "linux"
and Path("/proc/sys/kernel/yama/ptrace_scope").exists()
and int(Path("/proc/sys/kernel/yama/ptrace_scope").read_text()) >= 1,
"needs Linux with ptrace_scope >= 1"
)This feels so fragile!
_remote_debugging permissions error on Linux_remote_debugging permissions error on Linux
Yeah, I think this will haunt us in the future. For now I tested manually. We can make a future PR if we find more problems in the future in this area but it wold be great to do some big audit of this. |
|
Thanks @ivonastojanovic for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
|
GH-150339 is a backport of this pull request to the 3.15 branch. |
|
Thanks a lot @ivonastojanovic ! |
…H-150012) (#150339) gh-149619: Fix `_remote_debugging` permissions error on Linux (GH-150012) When running profiling on Linux without sudo, attempts to read process memory would fail with the misleading error 'Failed to find the PyRuntime section in process <pid> on Linux platform'. The actual issue is a permissions error because profiling was not run with sudo. We were clearing the exception on Linux when trying to read memory, instead, we should bubble up the permissions error and show it properly. (cherry picked from commit 0563890) Co-authored-by: ivonastojanovic <80911834+ivonastojanovic@users.noreply.github.com>
|
Spent some time auditing all error paths of the remote debugging module and found a bunch of stuff. See #150349 |
When running profiling on Linux without sudo, attempts to read process memory would fail with the misleading error 'Failed to find the PyRuntime section in process on Linux platform'.
The actual issue is a permissions error because profiling was not run with sudo. We were clearing the exception on Linux when trying to read memory, instead, we should bubble up the permissions error and show it properly.
_remote_debugging: incorrect error forprocess_vm_readv()w/EPERMwhen detecting the cookie #149619