Closed njsmith closed 2 years ago
Thank you for using our project! The panics and infinite loops are not expected, I don't yet have a good idea of how this is possible. I will look over your linke code and take some notes, in case I spot something:
// XX this error reporting is terrible
we can make it send (in 0.3), please open and Issue about that.// why can't I call ::new on this?
you can call DependencyConstraints::default()
but we should probably add a new
.looking over resolve.rs, I have not found anything suspicious. It looks like for purposes of minimization, you can copy things into a OfflineDependencyProvider
and send us a serialization of it for us to add to our tests.
"This must be a decision"
is part of satisfier
witch is also in your stack traces, and it is mostly doing intersection
on a small set of Ranges
. So ether we have a bug in our intersection
or your Version
has some kind of inconsistencies in Ord
, Eq
, or pubgrub::version::Version
. Maybe you can replace the panic in the pubgrub code with something that outputs self.dated_derivations
, incompat_term
, and start_term
. That may give us a small set of Version
s to try and find the problem.
looking over resolve.rs, I have not found anything suspicious. It looks like for purposes of minimization, you can copy things into a OfflineDependencyProvider and send us a serialization of it for us to add to our tests.
That's actually the first thing I tried, but I couldn't reproduce it that way. Which means I'm definitely missing something, but it doesn't point to what...
"This must be a decision" is part of satisfier witch is also in your stack traces, and it is mostly doing intersection on a small set of Ranges. So ether we have a bug in our intersection or your Version has some kind of inconsistencies in Ord, Eq, or pubgrub::version::Version. Maybe you can replace the panic in the pubgrub code with something that outputs self.dated_derivations, incompat_term, and start_term. That may give us a small set of Versions to try and find the problem.
Oo, this is super helpful at narrowing things down, I'll go poke around in there now.
Ah-hah! It seems that the problem has something to do with 0.19
versus 0.19.0
:
accum_term = Positive(Range { segments: [(Version(Version { epoch: 0, release: [0, 19], pre: None, post: None, dev: None, local: [] }), Some(Version(Version { epoch: 0, release: [0, 19], pre: None, post: Some(1), dev: Some(0), local: [] })))] })
incompat_term = Positive(Range { segments: [(Version(Version { epoch: 0, release: [0, 19, 0], pre: None, post: None, dev: None, local: [] }), Some(Version(Version { epoch: 0, release: [0, 19, 0], pre: None, post: Some(1), dev: Some(0), local: [] })))] })
These are supposed to be equivalent for PEP 440's Ord and Eq, but apparently something is going wrong there. And indeed, if I run with trio == 0.19.0
instead of trio == 0.19
, then I get a proper failed resolution error. So I think this is my bug, not yours :-).
Yep, found it: https://github.com/relrod/pep440-rs/issues/2
In payment for the debugging assistants, I would happily accept a PR improving the panic message. :-) It should mention that:
Ord
, Eq
, or pubgrub::version::Version
package
where it occurredaccum_term
and incompat_term
while you are at it
Hello!
pubgrub
is super cool, thanks for working on it! I hacked together a python package resolver: https://github.com/njsmith/posy/blob/main/src/resolve.rsIt seems to work well for simple cases. However, I've been doing some experiments with feeding my resolver intentionally conflicting constraints, to see what happens, and I've been hitting panics and infinite loops inside
pubgrub
. Not sure if these are my fault or not, and I haven't managed to reproduce it with a more minimal setup yet, so idk, might not even be your bug. But I figured I'd post here in case you have any ideas :-)Here's requesting
trio == 0.19
andattrs == 19.1
, which is impossible because trio v0.19 has a dependency on attrs >= 19.2.0. But pubgrub panics with "this must be a decision":::satisfier at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/partial_solution.rs:410:17 2: pubgrub::internal::partial_solution::PartialSolution
::find_satisfier at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/partial_solution.rs:330:17 3: pubgrub::internal::partial_solution::PartialSolution
::satisfier_search at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/partial_solution.rs:283:29 4: pubgrub::internal::core::State
::conflict_resolution at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/core.rs:173:58 5: pubgrub::internal::core::State
::unit_propagation at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/core.rs:139:52 6: pubgrub::solver::resolve at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/solver.rs:95:9 7: posy::resolve::resolve at ./src/resolve.rs:29:18 8: posy::main at ./src/main.rs:78:9 9: core::ops::function::FnOnce::call_once at /home/njs/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. ```
Or, here's a very similar case --
trio >= 0.17
,attrs == 19.1
. Again, all versions of trio >= 0.17 have a dependency on attrs >= 19.2, so this is unsatisfiable. In this case, I get an infinite loop:Here's a few random backtraces taken from the infinite loop:
::satisfier (self=0x555556467270, package=0x7ffff739a048, incompat_term=0x7ffff739a0a8, start_term=..., store=0x7fffffff4330) at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/partial_solution.rs:391 #13 0x00005555557d4faf in pubgrub::internal::partial_solution::PartialSolution
::find_satisfier (incompat=0x7ffff7399e90, package_assignments=0x7fffffff4308, store=0x7fffffff4330) at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/partial_solution.rs:330 #14 0x00005555557d53b6 in pubgrub::internal::partial_solution::PartialSolution
::satisfier_search (self=0x7fffffff4308, incompat=0x7ffff7399e90, store=0x7fffffff4330) at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/partial_solution.rs:283 #15 0x00005555557d7882 in pubgrub::internal::core::State
::conflict_resolution ( self=0x7fffffff4218, incompatibility=...) at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/core.rs:173 #16 0x00005555557d71ee in pubgrub::internal::core::State
::unit_propagation ( self=0x7fffffff4218, package=...) at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/core.rs:139 #17 0x0000555555733f0f in pubgrub::solver::resolve (dependency_provider=0x7fffffffba10, package=..., version=...) at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/solver.rs:95 #18 0x00005555557feee4 in posy::resolve::resolve (requirements=0x7fffffffd990, env=0x7fffffffdad8, index=0x7fffffffd860, preferred_versions=0x7fffffffdb10, consider_prereleases=...) at src/resolve.rs:29 #19 0x00005555557938c6 in posy::main () at src/main.rs:78 (gdb) ``` ``` #0 pubgrub::range::Range::intersection (self=0x7fffffff0348, other=0x7fffffff08a0)
at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/range.rs:236
#1 0x000055555573364d in pubgrub::term::Term::intersection (self=0x7fffffff06f0,
other=0x7fffffff0898)
at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/term.rs:87
#2 0x00005555557d661d in pubgrub::internal::partial_solution::PackageAssignments
::satisfier (self=0x5555564676e0, package=0x7ffff6c0f418, incompat_term=0x7ffff6c0f478, start_term=..., store=0x7fffffff4330) at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/partial_solution.rs:391 #3 0x00005555557d4faf in pubgrub::internal::partial_solution::PartialSolution
::find_satisfier (incompat=0x7ffff6c0f410, package_assignments=0x7fffffff4308, store=0x7fffffff4330) at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/partial_solution.rs:330 #4 0x00005555557d53b6 in pubgrub::internal::partial_solution::PartialSolution
::satisfier_search (self=0x7fffffff4308, incompat=0x7ffff6c0f410, store=0x7fffffff4330) at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/partial_solution.rs:283 #5 0x00005555557d7882 in pubgrub::internal::core::State
::conflict_resolution ( self=0x7fffffff4218, incompatibility=...) at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/core.rs:173 #6 0x00005555557d71ee in pubgrub::internal::core::State
::unit_propagation ( self=0x7fffffff4218, package=...) at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/internal/core.rs:139 #7 0x0000555555733f0f in pubgrub::solver::resolve (dependency_provider=0x7fffffffba10, package=..., version=...) at /home/njs/.cargo/registry/src/github.com-1ecc6299db9ec823/pubgrub-0.2.1/src/solver.rs:95 #8 0x00005555557feee4 in posy::resolve::resolve (requirements=0x7fffffffd990, env=0x7fffffffdad8, index=0x7fffffffd860, preferred_versions=0x7fffffffdb10, consider_prereleases=...) at src/resolve.rs:29 #9 0x00005555557938c6 in posy::main () at src/main.rs:78 ```
Any suggestions?