Check for mismatched package and distribution names on resolver thread (#13088)
Some checks are pending
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / build binary | windows aarch64 (push) Blocked by required conditions
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / typos (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / build binary | linux libc (push) Blocked by required conditions
CI / check system | python on macos x86-64 (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / lint (push) Waiting to run
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / build binary | linux musl (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / build binary | windows x86_64 (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / build binary | freebsd (push) Blocked by required conditions
CI / ecosystem test | pydantic/pydantic-core (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / smoke test | linux (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / smoke test | macos (push) Blocked by required conditions
CI / smoke test | windows x86_64 (push) Blocked by required conditions
CI / smoke test | windows aarch64 (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | deadsnakes python3.9 on ubuntu (push) Blocked by required conditions
CI / integration test | free-threaded on linux (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / integration test | free-threaded python on github actions (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / integration test | uv_build (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on opensuse (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows x86-64 (push) Blocked by required conditions
CI / check system | x86-64 python3.13 on windows aarch64 (push) Blocked by required conditions
CI / check system | windows registry (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.8 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.11 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.11 on windows x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on windows x86-64 (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows x86-64 (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions

This PR restores the `bogus_redirect` test that was
non-deterministically hanging (reverting #13076).

Mismatched package and distribution names were causing uv to hang prior
to #12917 (which added the `bogus_redirect` test). But with that fix, uv
was only checking for mismatched package names on the main thread (and
not the resolver thread). This allowed for a race condition which would
prevent uv from ever doing the check, triggering the original hang
condition. This PR adds the check to the resolver thread to prevent this
race condition.
This commit is contained in:
John Mumm 2025-04-24 15:18:01 +02:00 committed by GitHub
parent 43e5a6ef96
commit 9fb19cd43c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 82 additions and 4 deletions

View file

@ -1320,7 +1320,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
candidate.choice_kind(),
filename,
);
self.visit_candidate(&candidate, dist, package, pins, request_sink)?;
self.visit_candidate(&candidate, dist, package, name, pins, request_sink)?;
let version = candidate.version().clone();
Ok(Some(ResolverVersion::Unforked(version)))
@ -1480,7 +1480,14 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
base_candidate.choice_kind(),
filename,
);
self.visit_candidate(&base_candidate, base_dist, package, pins, request_sink)?;
self.visit_candidate(
&base_candidate,
base_dist,
package,
name,
pins,
request_sink,
)?;
return Ok(Some(ResolverVersion::Unforked(
base_candidate.version().clone(),
@ -1527,8 +1534,15 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
.collect::<Vec<_>>()
.join(", ")
);
self.visit_candidate(candidate, dist, package, pins, request_sink)?;
self.visit_candidate(&base_candidate, base_dist, package, pins, request_sink)?;
self.visit_candidate(candidate, dist, package, name, pins, request_sink)?;
self.visit_candidate(
&base_candidate,
base_dist,
package,
name,
pins,
request_sink,
)?;
let forks = vec![
VersionFork {
@ -1551,6 +1565,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
candidate: &Candidate,
dist: &CompatibleDist,
package: &PubGrubPackage,
name: &PackageName,
pins: &mut FilePins,
request_sink: &Sender<Request>,
) -> Result<(), ResolveError> {
@ -1562,6 +1577,13 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
if matches!(&**package, PubGrubPackageInner::Package { .. }) {
if self.dependency_mode.is_transitive() {
if self.index.distributions().register(candidate.version_id()) {
if name != dist.name() {
return Err(ResolveError::MismatchedPackageName {
request: "distribution",
expected: name.clone(),
actual: dist.name().clone(),
});
}
// Verify that the package is allowed under the hash-checking policy.
if !self
.hasher