When a compiler or post-compilation hook leaves a directory symlink in a temporary build, DiskCacheEntry cleanup follows the link and removes files from its target. Dangling symlinks are skipped, which can also leave temporary directories behind.
Reproduced at 8b3ef868705a3792cc1a14ab570b539f72fd3d94 on Linux, using disposable directories:
- Create an outside directory containing a sentinel file.
- Obtain a cache miss with
DiskCache::entry.
- Create a directory symlink inside
entry.path pointing to the outside directory.
- Destroy the uncommitted entry, as happens when compilation throws.
- The sentinel has been deleted. With a dangling link instead, the temporary entry is not fully removed.
Expected: cleanup removes the symlink itself and preserves its target. The same expectation applies when the path passed to the cleanup helper is itself a symlink.
safe_remove_all uses path-based exists and is_directory, which follow links before recursion. This reproduction uses stable paths in a trusted cache; it does not require a concurrent path replacement.
The custom walker can be retained while classifying each entry with symlink_status. Regression coverage should include directory, file, and dangling links, ordinary directories, and cleanup after a failing CUDA post-hook.
When a compiler or post-compilation hook leaves a directory symlink in a temporary build,
DiskCacheEntrycleanup follows the link and removes files from its target. Dangling symlinks are skipped, which can also leave temporary directories behind.Reproduced at
8b3ef868705a3792cc1a14ab570b539f72fd3d94on Linux, using disposable directories:DiskCache::entry.entry.pathpointing to the outside directory.Expected: cleanup removes the symlink itself and preserves its target. The same expectation applies when the path passed to the cleanup helper is itself a symlink.
safe_remove_alluses path-basedexistsandis_directory, which follow links before recursion. This reproduction uses stable paths in a trusted cache; it does not require a concurrent path replacement.The custom walker can be retained while classifying each entry with
symlink_status. Regression coverage should include directory, file, and dangling links, ordinary directories, and cleanup after a failing CUDA post-hook.