Skip to content

fix(seq): huge integer operands terminate exactly instead of falling into the float loop (#1860) - #1866

Merged
caomengxuan666 merged 2 commits into
mainfrom
fix/1860-seq-huge-integers
Nov 23, 2026
Merged

caomengxuan666 merged 2 commits into
mainfrom
fix/1860-seq-huge-integers

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

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_fast digit 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 by try_exact_run's long-double parity guard into the f64 print_numbers loop. 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 1000000000000000000000 once; a step-201 range prints the 192-spaced ulp grid; negative/-w/multi-byte--s equal 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 != 0 gate, so the eject-to-float branch no longer fires for integer cases. No functions or mechanisms are removed; print_numbers and both fast paths are untouched.

Net lines

rust2/crates/winux-cmds/src/seq.rs only: production +20/-4 (the gate plus explanatory comments and a module-doc note), tests +67/-0. Total +87/-4.

Evidence

  • Fail-first (pins-only head 19d55b72, CMake CI run 45156132597): rust-tests 1070 passed / 1 failed — the sole failure is the new pin huge_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 via seq_fast, as analyzed.
  • Fix head 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 at bcc24eb7: both workflows success.
  • New pins cover: the reported equal shape, huge unequal, step 201 equal + range, negative equal + decreasing range, -w equal, multi-byte -s equal — 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.
  • X299 real-machine verification is still owed: both X299 channels were down today (the reverse tunnel port is not listening on the cloud host), so the Windows CI runners carried the test evidence for this delivery.

Residuals (out of scope, unchanged by this PR)

  • -f with huge equal operands still runs the f64 loop (~65537 lines of 1e+21 vs GNU's 33 long-double duplicates) — the documented f64-vs-long-double class; fixing it means changing the float engine itself, a separate mechanism.
  • Integer operands beyond i128 (39+ digits) past the fast-path boundary, and fractional huge shapes (prec > 0), keep the previous guard/float behavior exactly.

…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.
@caomengxuan666
caomengxuan666 merged commit 28b2d2b into main Nov 23, 2026
30 of 32 checks passed
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.

1 participant