Skip to content

A Laplace determinant came back with another expression's integers in it, once, under a parallel test run #1219

Description

@Rafael-SOWNet

Seen once, in a parallel run of the unit tests (--filter "FullyQualifiedName!~Calculus", on a branch whose only change is a new summation closed form, nothing on the determinant's path). FractionFreeDeterminantTest.EliminationAgreesWithLaplaceWhereverBothApply — seeded with Random(4242), so the 300 matrices are the same every run — reported one disagreement:

[[c, -2, -2, -3], [0, a, 0, c], [2, 4, -2, 1], [2, 0, 0, a]]:
  elimination: -2 * a ^ 2 * c + 4 * a ^ 2 - 16 * a + 24 * c
  Laplace:     c * a * (-2) * a
               + 1236922277952940091218024611172685383149091942903829242732965561451168636116232649696243016007680
               + (-2) * (-a * (2 * a + -2) + c * (-8))
               + -35579337652911028425208263692778425096184356634099149498205671334037140067462330718355456

The elimination is right. The Laplace expansion, matrix.InnerMatrix.DeterminantLaplace().InnerSimplified, came back with two of its cofactor terms replaced by ninety-digit integers that have nothing to do with the matrix. The same test:

  • passes alone on the same build, every time tried;
  • passed on an immediate rerun of the same chunk on the same build;
  • passes in the same chunk on master's build (27ed5b53).

So the input is fixed and the only variable is what else was running. A term of an expression being another expression's number under a parallel run is the signature of shared state read across threads — a cache keyed on something two unequal entities share, or a non-concurrent dictionary written from two tests at once — rather than anything in the determinant. The two integers are not obviously any known value (not a factorial, not a power of two), which suggests they are intermediate results of some other test's arithmetic.

Not reproduced on demand, so no fix is attached; this is the record so that the next sighting has a first one to compare with. Things worth doing when it is next seen: run the chunk with -- xunit.parallelizeTestCollections=false to confirm it goes away serially; log GetHashCode of the offending cofactor products against the big integers' sources; check every static cache on the InnerSimplified / Evaled path for a key that is a hash without an equality.

Log lines from the run, for the record (the test name, the matrix and both outputs are verbatim above).

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Activity

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

    BugA serious math/runtime error

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions