ucrt: set ERANGE when a checked float wrapper or ldexpf overflows #52
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/52"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Repla09 on 2026-11-26T11:31:07Z.
The math module sets
ERANGEfor an infinity from finite arguments (docs/native-host.md), but the float forms (expf,powf,coshf,hypotf,ldexpfand the rest made by theunary!/binary!macros) checked the double result before rounding it to a float. A float overflow is still finite as a double, soexpf(100)andldexpf(1, 200)returned infinity witherrnountouched, whileexp(1000)setERANGE.Now the result is checked after rounding it to the float it returns.
a_float_that_overflows_sets_erangefails without the fix (errno0, not 34) and checks five overflowing calls plus a finite one that leaveserrnoalone.Testing
cargo test --target x86_64-apple-darwin -p victory-hlepasses (220 unit, 15 native_probe; the D3D12 probe test skipped, no Metal Shader Converter here).x86_64-apple-darwinshows no new warnings;rustfmt --checkandcargo xtask policypass.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T11:42:45Z.
Review: CHANGES_REQUESTED
The five overflow cases all reproduce on main and pass here. Two things:
ldexpf, in the title and in the UCRT notes.fdimf,scalbnfandscalblnfstill return infinity without settingerrno. That predates this PR, so another PR or a mention is fine.errnobefore the success check and verify it survives. Also include a true infinity from an infinite input, so the test tells a valid infinity apart from an overflow.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Repla09 on 2026-11-26T11:50:16Z.
Thanks. Retitled to the checked float wrappers plus
ldexpf, and the UCRT notes say the same, mentioning thatfdimf,scalbnfandscalblnfstill set no errno (left for another PR). In 2315032 the test seeds errno = 7 and checks it survives a finite result and infinities from infinite inputs (expf(inf),powf(inf, 2),ldexpf(inf, 1)), so a valid infinity is told apart from an overflow. Rebased onto main.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T12:01:59Z.
Review: DISMISSED
Thanks for addressing the earlier requests; the regression passes under Rosetta and fails against main. Approved.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T12:09:35Z.
Approved, but #51 just landed and both edit the UCRT
errnoparagraph indocs/native-host.md, so this now conflicts. Please rebase on main (or merge main in) and resolve that paragraph; I'll merge once CI is green.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Repla09 on 2026-11-26T12:13:17Z.
Rebased onto main after #51 merged: both added a sentence to the same
errnoline in native-host.md, so the conflict kept both (the remquo guarantee, then the float-wrapper rule). No code change.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T12:41:08Z.
Review: APPROVED
Thanks for the rebase. The docs paragraph now keeps both the remquo and the ERANGE sentences, and the code is unchanged. Approved.