Skip to content

regression: assertion left == right failed but it depends on library-unstable details #128899

Closed

Description

@BoxyUwU

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Aug 9, 2024
  2. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 9, 2024
  3. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 9, 2024
  4. workingjubilee commented on Aug 10, 2024

    @workingjubilee
    Member

    It is probably the case that these include incorrect sort algorithm impls.

    I am bringing these to the attention of @orlp and @Voultapher if they wish to inspect the regressions further.

  5. workingjubilee commented on Aug 10, 2024

    @workingjubilee
    Member

    I think I am wrong for some most, actually.

    bevy_serde_macros
    assertion `left == right` failed
    [INFO] [stdout]   left: {" Component3": Array [Array [Number(1), Object {"target": Number(0), "test_enum": Object {"ATest": String("test")}}]], " Component1": Array [Array [Number(0), Null], Array [Number(1), Null]], " Component2": Array [Array [Number(1), Object {"target": Number(0)}]]}
    [INFO] [stdout]  right: {"Component3": Array [Array [Number(1), Object {"target": Number(0), "test_enum": Object {"ATest": String("test")}}]], "Component2": Array [Array [Number(1), Object {"target": Number(0)}]], "Component1": Array [Array [Number(0), Null], Array [Number(1), Null]]}
    

    Either way, these do not seem to be directly from the sort changes.

  6. Voultapher commented on Aug 10, 2024

    @Voultapher
    Contributor

    coding-problems-practice has a now-failing-tests solution, but it actually is still correct according to the original problem.
    the tests seem to rely on sort_unstable_by having sorted things a certain way,

    sort_unstable* is unstable as the name says and the new implementation is deterministic as the previous one was, but it produces a different equal element ordering than the one before, so a test that relies on one specific order but uses sort_unstable is only valid for one version of Rust.

    however, the original problem specifically mentions that it's okay to get either "eert" or "eetr"

    I think the correct way to test that would be to do stable sort or assert_matches!(val, "eert" | "eetr").

  7. Voultapher commented on Aug 10, 2024

    @Voultapher
    Contributor

    atrocious_sort: appears to be failing in a sort, yes, but is specifically failing on sleep_sort only. did we change something about concurrency? https://github.com/Chromfalke/AtrociousSort/blob/main/src/algorithms/sleep_sort.rs

    Looking at the implementation, it sleeps for milliseconds, I fail to see how that could ever work reliably. The OS can decide to wake the threads up at some later point in time, sleep does not guarantee a fixed wakeup time. Plus it doesn't use latches, so it's spawn + sleep before the next thread is spawned. IMO that implementation is just plain broken.

  8. Voultapher commented on Aug 10, 2024

    @Voultapher
    Contributor

    I'm a little surprised by how many instances there are of relying on the order of hashmaps, the order is randomized with the default hasher. Looking at the linked code they seem to be using the default hasher, how come these tests ever reliably work during local development? What am I missing here?

  9. Voultapher commented on Aug 10, 2024

    @Voultapher
    Contributor

    gaffer
    Other initial hypothesis is that the library is doing panic recovery. Perhaps some other library in its dep tree is sorting but then panic recovery occurs? survemobility/gaffer@f238bae

    I suspect it's just racy. I checked the project out locally and ran cargo t, on my initial run I got:

    test source::test::queued_resets_recurring ... FAILED
    
    failures:
    
    ---- source::test::queued_resets_recurring stdout ----
    thread 'source::test::queued_resets_recurring' panicked at src/source.rs:320:9:
    assertion `left == right` failed
      left: [Tester(3), Tester(2), Tester(1)]
     right: [Tester(2)]
    
    
    failures:
        source::test::queued_resets_recurring
    
    test result: FAILED. 36 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
    

    Which is a completely different test, and the one in the crater run passed. Second run all tests pass.

  10. orlp commented on Aug 10, 2024

    @orlp
    Contributor

    @workingjubilee I find the proxmox-api case very strange: https://github.com/datdenkikniet/proxmox-api/blob/7d7540839371e3a58837b049997fe5fb8816d0cf/proxmox-api/src/types/multi.rs#L241-L255

    Note that the portion of the serde output that was changed is actually a BTreeMap, not a HashMap.

  11. workingjubilee commented on Aug 10, 2024

    @workingjubilee
    Member

    @orlp Thanks for catching that! I retract my comments re: "iterating over a hashmap" for that library, but it still seems very odd.

  12. workingjubilee commented on Aug 10, 2024

    @workingjubilee
    Member

    Somewhat shockingly, the Project Euler code is also operating with a hashmap: https://github.com/chubei/project_euler/blob/d100bed4c6b7c417276ccba051567c53ed869d40/src/lib.rs#L39-L48

    I really expected that one to be due to sorting issues...

    I'm a little surprised by how many instances there are of relying on the order of hashmaps, the order is randomized with the default hasher. Looking at the linked code they seem to be using the default hasher, how come these tests ever reliably work during local development? What am I missing here?

    There is a certain sort of person who only ever writes and runs a test once.

    I do not mean to accuse, but if they only ran the test a few times, it is possible the hashes happened to work out for them. Even if the hashing perfectly randomizes the keys, if you assert on the order of only 2 items, then it comes up as a coinflip either way. It's reasonable for that to pass 2-4 times in a row if you are lucky.

  13. workingjubilee commented on Aug 10, 2024

    @workingjubilee
    Member

    I downloaded workpool and reran its tests a few times. It's another racy case. I think we've correctly identified racy library tests in:

    • atrocious_sort
    • gaffer
    • workpool

    And what seem to be definitely hashmap problems:

    • chubei/project-euler
    • rainhead/rust-anagrams
    • rwini

    Unless these are fixed promptly, we should ignore those in future crater runs which cover tests.

    Correctly root-caused to the sort impl, but known accepted breakage:

    • lht102/coding-problems-practice

    MPCHomeControl is a float problem, so I'll bring it to #128898

    That leaves the following as still open questions as to why the test is failing to begin with:

    • bevy_serde_macros
    • hopscotch
    • proxmox-api
  14. 8 remaining items

  15. orlp commented on Aug 11, 2024

    @orlp
    Contributor

    Would it be possible to add a clippy warning to some code patterns which attempt to assert an expression that depends on hashmap iteration order? Obviously we can't catch everything, but perhaps some of the more common patterns?

  16. changed the title [-]regression: assertion `left == right` for stuff that looks sorting related[/-] [+]regression: assertion `left == right` failed because people iterate hashmaps[/+] on Aug 11, 2024
  17. changed the title [-]regression: assertion `left == right` failed because people iterate hashmaps[/-] [+]regression: assertion `left == right` failed because of comparisons that depend on library-unstable details[/+] on Aug 11, 2024
  18. changed the title [-]regression: assertion `left == right` failed because of comparisons that depend on library-unstable details[/-] [+]regression: assertion `left == right` failed but it depends on library-unstable details[/+] on Aug 11, 2024
  19. workingjubilee commented on Aug 11, 2024

    @workingjubilee
    Member

    I guess I retract my retraction regarding proxmox-api???

  20. workingjubilee commented on Aug 11, 2024

    @workingjubilee
    Member

    I guess we should test a revert of #125174

  21. workingjubilee commented on Aug 11, 2024

    @workingjubilee
    Member

    Hm, #125174 was cratered.

  22. workingjubilee commented on Aug 11, 2024

    @workingjubilee
    Member

    The proxmox-api tests may work on the next crater run, so let's not exclude those.

    I've opened some PRs and issues on the relevant crates in the hopes of them fixing their code so that we can continue using their test data:

    It seems unlikely these will all be resolved by the next beta crater run.

    In particular, the gaffer tests seem to be completely insoluble as it is an issue in essentially all the tests, so let's just skip that crate's tests from now on.

  23. workingjubilee commented on Aug 11, 2024

    @workingjubilee
    Member

    I have opened some followups:

    Everything else is accepted breakage, or (hopefully) will be published and fixed for the next beta crater, so I think we're done here.

  24. workingjubilee commented on Aug 11, 2024

    @workingjubilee
    Member

    Thank you for playing, everyone!

  25. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Aug 12, 2024
  26. added a commit that references this issue on Aug 24, 2024
  27. added a commit that references this issue on Sep 29, 2024
  28. added a commit that references this issue on Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions