rust-subprocess icon indicating copy to clipboard operation
rust-subprocess copied to clipboard

Fix test that calls setenv() without synchronization

Open mcy opened this issue 3 years ago • 0 comments

This test is flaky under the following interleaving:

  • exec_to_string() grabs MUTATE_ENV.
  • env_inherit_set() calls temp_env_var() which calls env::set_var().
  • exec_to_string() executes some asserts, one of which fails because the other test messed with the environment in a way exec_to_string() did not expect.
  • exec_to_string() panics and poisons MUTATE_ENV.
  • env_inherit_set() grabs the lock and panics because it's poisoned.

Taking the lock before setenv fixes this.

mcy avatar May 16 '22 14:05 mcy