-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fallback to /proc/$pid/mem when process_vm_readv() is unavailabe #4
Fallback to /proc/$pid/mem when process_vm_readv() is unavailabe #4
Conversation
If the Linux kernel was built without support for process_vm_readv() (CONFIG_CROSS_MEMORY_ATTACH is unset in kernel config) a call to this function will fail with Function not implemented (os error 38) aka ENOSYS. To still support reading process memory on this platform we fallback to reading /proc/$pid/mem.
98110bf
to
27863c7
Compare
@sebageek CI is green now on |
Thanks for this! This helps a lot - I'm surprised how many people hit this problem with py-spy |
@benfred Could you please cut a release with this patch? The 0.2.0 crate doesn't have this change. Also, the tags on the GH repo are not in sync :) |
@nehaljwani I've pushed out 0.2.1 to crates.io with this change (and am in the process of getting this change into dependant packages like remoteprocess/py-spy). |
The latest remoteprocess code includes a workaround for the case where the linux kernel was compiled without process_vm_readv support (by falling back to /proc/PID/mem: benfred/read-process-memory#4). Closes rbspy#196
If the Linux kernel was built without support for process_vm_readv() (CONFIG_CROSS_MEMORY_ATTACH is unset in kernel config) a call to this function will fail with Function not implemented (os error 38) aka ENOSYS. To still support reading process memory on this platform we fallback to reading /proc/$pid/mem.
If the Linux kernel was built without support for process_vm_readv()
(CONFIG_CROSS_MEMORY_ATTACH is unset in kernel config) a call to this
function will fail with Function not implemented (os error 38) aka
ENOSYS. To still support reading process memory on this platform we
fallback to reading /proc/$pid/mem.
This is intended as a fix for benfred/py-spy/issues/22. To reproduce this I recompiled my current kernel with
CONFIG_CROSS_MEMORY_ATTACH
disabled.This yielded the
Error: Function not implemented (os error 38)
. The patch in this PR subsequently fixed this error.I'm still a bit unhappy with the fallback, as each time memory is read an attempt to use
process_vm_readv()
is made, which is one extra syscall per read. Additionally the filehandle toprocmem
could be cached per pid, saving two additional syscalls (open, close). This might lead to an API change though, so I wanted to discuss this before wildly implementing something. In any case, the code in this PR shouldn't change the performance for current users of this library. It will only be slower in cases where it would have errored out beforehand.Shoutout to @eqv for rust support!