conda / rattler

Rust crates to work with the Conda ecosystem.
BSD 3-Clause "New" or "Revised" License
253 stars 54 forks source link

Solving panics due to incorrect comparison function #888

Open mdekstrand opened 1 day ago

mdekstrand commented 1 day ago

Checklist

What happened?

Rust 1.81 introduce stricter checks for the correctness of Ord and PartialOrd implementations when sorting, panicing when it detects a non-total ordering instead of proceeding and allowing the sorted results to be incorrect. This causes Rattler's tests, and Pixi's solving, to fail when built with Rust 1.81.

Test error output ```console $ cargo +1.81.0 test ... failures: ---- channel_priority_strict stdout ---- thread 'channel_priority_strict' panicked at library/core/src/slice/sort/shared/smallsort.rs:862:5: user-provided comparison function does not correctly implement a total order ---- channel_specific_requirement stdout ---- thread 'channel_specific_requirement' panicked at library/core/src/slice/sort/shared/smallsort.rs:862:5: user-provided comparison function does not correctly implement a total order ---- resolvo::test_solve_tensorboard stdout ---- thread 'resolvo::test_solve_tensorboard' panicked at library/core/src/slice/sort/shared/smallsort.rs:862:5: user-provided comparison function does not correctly implement a total order ---- resolvo::test_solve_quetz stdout ---- thread 'resolvo::test_solve_quetz' panicked at library/core/src/slice/sort/shared/smallsort.rs:862:5: user-provided comparison function does not correctly implement a total order ---- resolvo::test_solve_tensorflow stdout ---- thread 'resolvo::test_solve_tensorflow' panicked at library/core/src/slice/sort/shared/smallsort.rs:862:5: user-provided comparison function does not correctly implement a total order ---- compare_solve_tensorboard stdout ---- libsolv_c took 2139ms thread 'compare_solve_tensorboard' panicked at library/core/src/slice/sort/shared/smallsort.rs:862:5: user-provided comparison function does not correctly implement a total order ---- compare_solve_tensorflow stdout ---- libsolv_c took 3183ms thread 'compare_solve_tensorflow' panicked at library/core/src/slice/sort/shared/smallsort.rs:862:5: user-provided comparison function does not correctly implement a total order ---- compare_solve_quetz stdout ---- libsolv_c took 4744ms thread 'compare_solve_quetz' panicked at library/core/src/slice/sort/shared/smallsort.rs:862:5: user-provided comparison function does not correctly implement a total order failures: channel_priority_strict channel_specific_requirement compare_solve_quetz compare_solve_tensorboard compare_solve_tensorflow resolvo::test_solve_quetz resolvo::test_solve_tensorboard resolvo::test_solve_tensorflow test result: FAILED. 53 passed; 8 failed; 0 ignored; 0 measured; 0 filtered out; finished in 9.15s ```

This is likely the cause of prefix-dev/pixi#2122.

Additional Context

I discovered this issue because Homebrew builds Pixi with latest Rust, and my Pixi dependency solves were panicing.

tdejager commented 1 day ago

Ah yes we should definitely fix this, let's see if we can implement a correct total ordering for the things that error out.