Repository navigation
fix(seq): huge integer operands terminate exactly instead of falling into the float loop (#1860) - #1866
Merged
Conversation
…uard (#1860) try_exact_run's long-double parity guard ejected integer-valued cases (step past the fast-path bound, negative operands, -w, multi-byte separator) into the f64 print_numbers loop, whose ulp at 1e21 is 2048x the long-double one: equal huge operands repeated ~65537 times instead of terminating (the pre-rust2 engine never terminated). Integer stepping (print precision 0) is now exempt from the guard; fractional stepping keeps the guard and the float path unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1860. UNVERIFIED-BY-CAPTAIN.
Root cause
Two layers. The shipped binary the report was filed against still ran the pre-rust2 engine, whose float loop never terminated. On current main the plain reported shape is already covered by the
seq_fastdigit path — but every other integer-valued shape that misses the fast path's narrow gate (step past the 200 bound, a minus sign,-w, a multi-byte separator) was ejected bytry_exact_run's long-double parity guard into the f64print_numbersloop. At 1e21 the f64 ulp is 2048x GNU's long-double ulp, so equal huge operands repeated the rounded value ~65537 times instead of stopping (GNU long double stops after ~33).GNU 9.4 probed locally for the adjacent faces: plain/unequal/step<=200 integer shapes print exact digits on the fast path; the fall-through shapes are long-double parse-rounding artifacts (step-201 equal prints rounded
1000000000000000000000once; a step-201 range prints the 192-spaced ulp grid; negative/-w/multi-byte--sequal shapes print 33 duplicate lines).Fix (single mechanism)
Integer stepping — print precision 0, i.e. first and step are integer texts and a fractional LAST only bounds the range — is exempt from the parity guard in
try_exact_run, so the existing exact-decimal domain (i128, checked arithmetic) generates those shapes with exact digits and exact termination. Fractional stepping keeps the guard, and the float path is byte-for-byte untouched: no decimal/float shape changes behavior.Documented divergence, same class this file already records for sub-ulp shapes: for the fall-through integer shapes GNU's bytes are its own rounding artifacts (rounded digits, duplicate lines); this PR prints the exact digits GNU's fast path prints for the same operands inside its boundary, with the correct count.
What this PR deletes
The parity guard's jurisdiction over integer stepping: the guard condition gains a
prec != 0gate, so the eject-to-float branch no longer fires for integer cases. No functions or mechanisms are removed;print_numbersand both fast paths are untouched.Net lines
rust2/crates/winux-cmds/src/seq.rsonly: production +20/-4 (the gate plus explanatory comments and a module-doc note), tests +67/-0. Total +87/-4.Evidence
19d55b72, CMake CI run 45156132597): rust-tests 1070 passed / 1 failed — the sole failure is the new pinhuge_integer_shapes_terminate_exact, panicking at the step-201 equal-operands assert; the plain reported shape and the huge-unequal shape already pass on main viaseq_fast, as analyzed.c68054c1(run 45157016582 / 45157016608): rust-tests pass (all 1071, new pin green); GNU differential oracle + compare + baseline-growth pass; i18n-drift pass; build-windows 3 of 4 legs pass and the differential baseline job passed after a long WSL oracle setup step; the remaining x64-default leg was still stuck in runner infrastructure at write-up time (PGO profile collection, the same infra face seen on other PRs) — no PR-unique failure in any settled job. Main baseline atbcc24eb7: both workflows success.-wequal, multi-byte-sequal — all with exact-output assertions. Existing float/exact-decimal pins (incl. the long-double boundary case) unchanged and green, so the decimal path is unregressed.Residuals (out of scope, unchanged by this PR)
-fwith huge equal operands still runs the f64 loop (~65537 lines of1e+21vs GNU's 33 long-double duplicates) — the documented f64-vs-long-double class; fixing it means changing the float engine itself, a separate mechanism.