|
pub fn test_main_static_abort(tests: &[&TestDescAndFn]) { |
|
// If we're being run in SpawnedSecondary mode, run the test here. run_test |
|
// will then exit the process. |
|
if let Ok(name) = env::var(SECONDARY_TEST_INVOKER_VAR) { |
|
unsafe { |
|
env::remove_var(SECONDARY_TEST_INVOKER_VAR); |
|
} |
https://doc.rust-lang.org/stable/std/env/fn.remove_var.html
AIUI since libtest is multithreaded, this is not a safe invocation of remove_var from the public safe test_main_static_abort function.
In practice, this doesn't matter: Rust libraries aren't manually calling this function, and if you can cause UB in a custom test harness I don't think it's that big a deal.
Filing for completeness' sake. It would probably make sense to at least document why this is okay here.
(This issue was found during an agentic safety audit using Gemini)
rust/library/test/src/lib.rs
Lines 206 to 212 in 7dc2c16
https://doc.rust-lang.org/stable/std/env/fn.remove_var.html
AIUI since libtest is multithreaded, this is not a safe invocation of
remove_varfrom the public safetest_main_static_abortfunction.In practice, this doesn't matter: Rust libraries aren't manually calling this function, and if you can cause UB in a custom test harness I don't think it's that big a deal.
Filing for completeness' sake. It would probably make sense to at least document why this is okay here.
(This issue was found during an agentic safety audit using Gemini)