Description
Is there an existing proposal for this?
- I have searched the existing proposals
Is your feature request related to a problem?
The cloud provider we use uses Flatcar Container Linux for its Kubernetes nodes. They compile their kernel with CONFIG_CROSS_MEMORY_ATTACH
not set, which means process_vm_readv
is not compiled in.
This means, if we try to use pystack remote <pid>
from a kubectl debug
container we see 💀 Engine error: Function not implemented 💀
.
Describe the solution you'd like
I think it could make sense to fall back to reading the memory through /proc/<pid>/mem
if process_vm_readv
returns ENOSYS
.
I should probably confess, I found this when testing one of my own tools, and was now testing pystack out of curiosity. I used pystack in the past though, before we switched cloud provider, and it would be a shame not to be able to call on it again when we need it.
This idea of using /proc/<pid>/mem
is what I've done in pymontrace, cakemanny/pymontrace#1 , based on what I read that py-spy
has done, so I can confirm it works (as a fallback for process_vm_writev
in my case).
I think the only real drawbacks are
- it causes between 2 and 4 extra syscalls per read (depending on how naive the implementation is)
- the memory has to be transferred through the kernel
but it's only a penalty for those with such a kernel.
Alternatives you considered
No response