rust-lang / rust-lang/rust

`std::env::{set_var, remove_var}` is called in tests without safety documentation

Open
#148,432 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-testsuite needs-triage
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Introduced by @ehuss in #136983 (36733f3bce9102647e8adf9d9a89cabcee9c4cdf, ef20a1b1f8c6dcbeb05da86634ca4516677a31b0), apparently without double-checking whether these functions were actually safe to call.

Found when trying to audit whether this repository's calls to these unsafe environment variable functions were safe. It doesn't appear to be the case to me, e.g.

https://github.com/rust-lang/rust/blob/f2bae990e89bf696e86706b524ac32ab72945438/library/test/src/term/terminfo/searcher/tests.rs#L13-L20

https://github.com/rust-lang/rust/blob/8c32e313cccf7df531e2d49ffb8227bb92304aee/library/std/src/process/tests.rs#L326-L332

https://github.com/rust-lang/rust/blob/ef20a1b1f8c6dcbeb05da86634ca4516677a31b0/library/std/src/env.rs#L571

The last example is even in user-facing documentation.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the calls in library/test/src/term/terminfo/searcher/tests.rs, library/std/src/process/tests.rs, and library/std/src/env.rs, starting with the cited lines and the safety requirements for environment-variable operations. Audit the surrounding tests and user-facing documentation, then verify that each affected call has an appropriate safety explanation or is otherwise addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation, operating-systems, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.