-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
os::unix::process::Command::exec
sometimes allocates, violating async signal safety
#130756
Comments
I just found the following note: rust/library/std/src/os/unix/process.rs Lines 226 to 230 in c22a421
Needless to say, my vote is that it's worth fixing :) |
note: according to libc authors it's not possible to use the standard library (or anything calling into libc) after using clone3 |
Thanks - that's really good to know. I'm probably okay using libc |
This is not an I-unsound issue in std because Command::exec does not make such a guarantee. The onus is on the users of If you want |
Thinking about it, changing the API would be difficult. Preparing a new environment is part of |
Sorry if I misunderstood, but why does it necessarily require heap allocation? Note that to be safe in this sense, it doesn't have to avoid allocations during setup - just during the call to
Isn't this just underspecified? A perfectly reasonable interpretation of the current docs is that it is careful about allocations, given the callout to execvp and all the fuss made about allocations in the documentation to |
I'm trying to build a small linux container runtime as part of another project. I'd like to do the moral equivalent of the following (extracted out and untested):
do_exec
inprocess_unix.rs
makes a big deal about the (un)safety of this operation, so I thought that it would be safe to useCommand::exec
. Unfortunately, I just caught a deadlock:Something in
capture_env
is allocating, which violates the rules around what you're allowed to do betweenfork
orclone
andexec
.As far as I can tell, this isn't documented one way or the other. So maybe this is a documentation bug, or I missed the documentation. Still, the amount of surface area that has the potential to allocate seems very small here - maybe the allocation would be possible to avoid? That would let me and others use the stdlib
Command
for this use-case, which would be pretty nice.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: