Skip to content

Fix division panics from oversized trial quotients - #47

Closed
ryanduguid wants to merge 1 commit into
quagmt:masterfrom
ryanduguid:fix/division-trial-overflow
Closed

ryanduguid wants to merge 1 commit into
quagmt:masterfrom
ryanduguid:fix/division-trial-overflow

Conversation

@ryanduguid

@ryanduguid ryanduguid commented Oct 1, 2026 •

Copy link
Copy Markdown

Summary

Fixes #46: valid divisions, including 3.4028236692093846347 / 1.8446744073709551616, panic in bits.Div64. Count equal normalised high words as four-word dividends and route oversized first or later trial quotients through the existing fallback.

safe trial      -> u128 quotient and remainder
oversized trial -> errOverflow -> existing big.Int fallback

Evidence

  • Before: Exact public and helper regressions panic on master. An equality-only correction still panics on the later trial.
  • After: Exact results pass across signs, precision 14, heap aliases and all 64 normalisation shifts. Full race/coverage suites pass on Linux amd64 Go 1.23.0 and 1.27.1.
  • All 22 fuzz targets pass make fuzz-all 20; division and the shared helper each pass a further 60-second run.
  • Nine existing division benchmarks retain zero allocations. The reported and small-value cases also allocate nothing; the later-trial example uses the fallback.
  • Configured lint retains seven baseline findings, with zero new findings including fuzz code.

Risk

An oversized estimate can now use the allocating fallback even when the final quotient fits in u128. Public APIs, truncation, signs and input immutability are preserved.

Unverified

Other operating systems and architectures. Upstream Test and Fuzz workflows report action_required with no jobs yet. Timing equivalence is unproven on this shared machine. Linux 386 passes the new regressions and all fuzz seeds; its full suite retains the same five TestAppendBinary failure names as master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decimal.Div panics with integer overflow for valid u128 operands

1 participant