mirror of
https://github.com/storytold/craft-libs.git
synced 2026-12-01 02:36:54 +01:00
Merge #712 (fix/linesweeper-perturbation-ulp-overflow) into integration/linesweeper
This commit is contained in:
commit
424e9b2a3f
3 files changed
+34
-1
No files matched your search
Vendored
+4
@@ -114,6 +114,9 @@ names, which is archived; its README says development moved off GitHub.
|
||||
`824b0791a750f7b27b8edcbb6c6244d0e629875e`. That commit is not in the GitHub repository the manifest
|
||||
names, which is archived; its README says development moved off GitHub.
|
||||
|
||||
`824b0791a750f7b27b8edcbb6c6244d0e629875e`. That commit is not in the GitHub repository the manifest
|
||||
names, which is archived; its README says development moved off GitHub.
|
||||
|
||||
Every file here except this one, `SOURCE.json` and the files under Local changes is byte for byte the
|
||||
file in the `.crate` archive. `SOURCE.json` records the hash of the `.crate` download
|
||||
(`source_archive_sha256`) and, for every file kept, the hash in the package (`source_sha256`) and the
|
||||
@@ -144,6 +147,7 @@ Every change here updates this table and `SOURCE.json` in the same commit.
|
||||
| The `paperjs` test's image comparison counts a difference in alpha | `Craft patch (image distance alpha)` | `tests/paperjs.rs` | `pixmap_distance_counts_coverage` |
|
||||
| `checkerboard(0)` and `slanted_checkerboard(0)` return empty collections; the inner count was `n - 1`, which overflowed | `Craft patch (empty checkerboard)` | `src/generators.rs`, `scripts/test-pdf-backends.sh` | `checkerboards_of_size_zero_and_one` |
|
||||
| `another_monotonic_bezier` returns `arbitrary::Error::IncorrectFormat` when no piece of the generated cubic increases in y; it returned that cubic, which can be horizontal | `Craft patch (flat cubic)` | `src/arbitrary.rs` | `another_monotonic_bezier_increases_in_y_or_fails` |
|
||||
| A ulp step past `f64::MAX` in the test-only `F64Perturbation::apply` gives infinity; `Ulp(2)` of `f64::MAX` gave NaN | `Craft patch (ulp overflow)` | `src/perturbation.rs` | `ulp_step_past_f64_max_is_infinite` |
|
||||
|
||||
Every change here updates this table and `SOURCE.json` in the same commit. To take a new linesweeper
|
||||
release, unpack the crates.io package, carry these changes over, regenerate `SOURCE.json`, and run the
|
||||
|
||||
Vendored
+3
@@ -64,6 +64,7 @@
|
||||
"In `src/curve/mod.rs`, `CurveOrder::next_touch_after(y)` walks the order once and compares each touch with `y`, so a touch that follows a touch containing `y` and a Left interval is no longer skipped, which made it return `None`."
|
||||
"`checkerboard` and `slanted_checkerboard` count the inner squares as `n.saturating_sub(1)` instead of `n - 1`, so `n = 0` gives empty collections instead of an overflow."
|
||||
"`another_monotonic_bezier` returns `arbitrary::Error::IncorrectFormat` when no piece of the generated cubic increases in y, instead of returning that cubic, which can be horizontal."
|
||||
"`F64Perturbation::apply` clamps a ulp step on a normal value to infinity when the bits reach the infinity encoding, instead of testing the sign bit, so `Ulp(2)` of `f64::MAX` gives infinity instead of NaN."
|
||||
],
|
||||
"files": [
|
||||
{ "path": ".cargo_vcs_info.json", "source_sha256": "47fba6a9dbdf445a5c97f783c9be62093035f9d5e5cdc2cf3216ad8259bcd8fc", "source_git_blob": null, "sha256": "47fba6a9dbdf445a5c97f783c9be62093035f9d5e5cdc2cf3216ad8259bcd8fc" },
|
||||
@@ -139,6 +140,8 @@
|
||||
{ "path": "src/perturbation.rs", "source_sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5", "source_git_blob": null, "sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5" },
|
||||
{ "path": "src/order.rs", "source_sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596", "source_git_blob": null, "sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596" },
|
||||
{ "path": "src/perturbation.rs", "source_sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5", "source_git_blob": null, "sha256": "a0108503efbcfa15a05b8a228d7891737e51f13fdd6c7d67dc4b4282847b14fb" },
|
||||
{ "path": "src/order.rs", "source_sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596", "source_git_blob": null, "sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596" },
|
||||
{ "path": "src/perturbation.rs", "source_sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5", "source_git_blob": null, "sha256": "86c27289a9e447a7a1022d3a5c35cf85490555a8904f28bc90a479dcbd49d4ca" },
|
||||
{ "path": "src/position.rs", "source_sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0", "source_git_blob": null, "sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0" },
|
||||
{ "path": "src/position.rs", "source_sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0", "source_git_blob": null, "sha256": "37686f512c4f4ded9fcbd19e8a736f1462ad2e883a65d88d32a7c441d512dc30" },
|
||||
{ "path": "src/segments.rs", "source_sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc", "source_git_blob": null, "sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc" },
|
||||
|
||||
+27
-1
@@ -64,7 +64,10 @@ impl FloatPerturbation for F64Perturbation {
|
||||
// Taking the absolute value sets the sign bit to zero, so the
|
||||
// addition should never overflow.
|
||||
let bits = f.abs().to_bits().checked_add_signed(delta).unwrap();
|
||||
let x = if bits & sign_bit != 0 {
|
||||
// Craft patch (ulp overflow): a step past `f64::MAX` reaches the
|
||||
// infinity and NaN encodings, not the sign bit, so it is clamped to
|
||||
// infinity there.
|
||||
let x = if bits >= f64::INFINITY.to_bits() {
|
||||
f64::INFINITY
|
||||
} else {
|
||||
f64::from_bits(bits)
|
||||
@@ -221,3 +224,26 @@ mod tests {
|
||||
assert_eq!(F64Perturbation::Ulp(1).apply(&-f64::from_bits(3)), -f64::from_bits(2));
|
||||
}
|
||||
}
|
||||
|
||||
// Craft patch (ulp overflow).
|
||||
#[cfg(test)]
|
||||
mod ulp_overflow_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn ulp_step_past_f64_max_is_infinite() {
|
||||
for (n, f, expected) in [
|
||||
(2, f64::MAX, f64::INFINITY),
|
||||
(127, f64::MAX, f64::INFINITY),
|
||||
(-2, -f64::MAX, f64::NEG_INFINITY),
|
||||
(1, f64::from_bits(f64::MAX.to_bits() - 1), f64::MAX),
|
||||
(-1, f64::MAX, f64::from_bits(f64::MAX.to_bits() - 1)),
|
||||
] {
|
||||
assert_eq!(
|
||||
F64Perturbation::Ulp(n).apply(&f),
|
||||
expected,
|
||||
"Ulp({n}) of {f}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user