Description
changing_bin_features_caches_targets
and rename_with_link_search_path
fail frequently on AppVeyor.
I have been doing some investigation and I have narrowed down some small, reliable reproductions. In general, it appears that attempting to rename or unlink a binary immediately after executing it causes problems. It's as-if there is a ghost entry left behind that causes further attempts to replace it with a new file, or to delete its parent to fail.
I have a test that does this in a loop, and it fails after some number of iterations (tends to happen very fast on AppVeyor):
- Link B to A
- Run A
- Delete A
- Link C to A
- Run A
- Delete A
The link calls will sometimes fail with "access denied". I have even noticed that A.exists()
is true immediately after the call to unlink
!
It is unrelated to hard-links, copying the file fails, too. It's also not specific to Rust, since I've been able to repro with Python.
I have Defender disabled, indexing disabled, and it's not related to mspdbsrv (although all 3 of those can make it substantially worse).
A workaround is to add a 1 second delay after executing a file before deleting it. However, I'm going to continue investigating to figure out why this happens.