-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
test: Unsafe usage of env::set_var
#7651
Labels
Comments
In this case, we can just remove the |
hawkw
added a commit
to linkerd/linkerd2-proxy
that referenced
this issue
Jan 20, 2022
Per rust-lang/rust#90308, this is potentially a data race. In practice, I don't think it was actually problematic here, but it also wasn't doing anything of value, so we should remove it. This is currently the only `env::set_var` or `env::remove_var` call in the proxy. Closes linkerd/linkerd2#7651
hawkw
added a commit
to linkerd/linkerd2-proxy
that referenced
this issue
Jan 20, 2022
Per rust-lang/rust#90308, this is potentially a data race. In practice, I don't think it was actually problematic here, but it also wasn't doing anything of value, so we should remove it. This is currently the only `env::set_var` or `env::remove_var` call in the proxy. To prevent uses of these functions in the future, I also added a `disallowed-methods` configuration in `.clippy.toml` to emit a warning for any uses of `std::env::set_var` and `std::env::remove_var`. Unfortunately, this required adding a `deny` attribute basically everywhere, which is why this diff touches so many files. Closes linkerd/linkerd2#7651
olix0r
pushed a commit
to linkerd/linkerd2-proxy
that referenced
this issue
Mar 30, 2022
Per rust-lang/rust#90308, this is potentially a data race. In practice, I don't think it was actually problematic here, but it also wasn't doing anything of value, so we should remove it. This is currently the only `env::set_var` or `env::remove_var` call in the proxy. To prevent uses of these functions in the future, I also added a `disallowed-methods` configuration in `.clippy.toml` to emit a warning for any uses of `std::env::set_var` and `std::env::remove_var`. Unfortunately, this required adding a `deny` attribute basically everywhere, which is why this diff touches so many files. Closes linkerd/linkerd2#7651 (cherry picked from commit 8f7be6f) Signed-off-by: Oliver Gould <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In the proxy's test initialization code, we use
std::env::set_var
to configure a log format:My understanding is that this is unsafe, per rust-lang/rust#90308, because our tests run in multiple threads. It would be great if we could avoid environment mutation in our codebase.
Can we remove this? Do we actually care about JSON formatting in our tests?
Are there tools we could use to, for instance, make clippy fail on new uses of
set_var
/remove_var
?The text was updated successfully, but these errors were encountered: