You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As described in the documentation, std::env::remove_var will become unsafe in a future version of Rust.
Even today the use of std::env::remove_var is unsound in multithreaded programs and can cause UB. In addition to that, env manipulation from non-Rust libs (libssytemd) can cause UB in Rust.
I think this is a problem for rust-systemd, because threads can be accessing the environment, while rust-systemd calls remove_var or calls into libsystemd which changes the env.
What do you think?
Thanks for your opinions :)
The text was updated successfully, but these errors were encountered:
Do you have a vague idea in what direction a fix could be?
I think this might be very hard to fix completely.
Even if all accesses are locked in Rust std (which is not the current plan, as far as I understand it), there can be unlocked C code that races with Rust code.
I suspect splitting the ListenFds::new(bool) into 2 functions where one is unsafe and the other is safe (and does not clear env vars). Also changing that fn to call the libsystemd function (probably) because the point of writing it ourselves was to avoid the env races.
I've taken a quick look at libsystemd itself, and it appears the only unsetting of env vars (unsetenv) is in this same sd-notify code, and there doesn't appear to be a place it's doing a setenv.
As described in the documentation,
std::env::remove_var
will become unsafe in a future version of Rust.Even today the use of
std::env::remove_var
is unsound in multithreaded programs and can cause UB. In addition to that, env manipulation from non-Rust libs (libssytemd) can cause UB in Rust.See the rust-lang/rust#27970 for more information.
I think this is a problem for
rust-systemd
, because threads can be accessing the environment, whilerust-systemd
callsremove_var
or calls intolibsystemd
which changes the env.What do you think?
Thanks for your opinions :)
The text was updated successfully, but these errors were encountered: