Skip to content

test(dng): find the maximum black per plane across the repeat pattern - #497

Merged
justin13888 merged 1 commit into
masterfrom
fix/110-dng-linearize
Sep 3, 2026
Merged

test(dng): find the maximum black per plane across the repeat pattern#497
justin13888 merged 1 commit into
masterfrom
fix/110-dng-linearize

Conversation

@justin13888

Copy link
Copy Markdown
Collaborator

Refs #110. Follow-up to #495.

One more gamut-dng survivor, found by re-running four shards that had been cut short during the
original sweep.

The survivor

crates/gamut-dng/src/linearize.rs:115:58: replace * with / in linearize

levels.black()[(j * cols + k) * spp + plane] walks the black-level repeat pattern to find each
plane's largest black, which sets that plane's scale. Mutating * spp to / spp collapses the
pattern's cells onto one index, so a plane's scale is computed from the wrong black.

Why it needed two things at once

The fixtures covered multiple planes, and they covered multi-cell repeat patterns — but never both
in the same image
, and either alone hides it:

  • with one sample per pixel, * spp and / spp are the same operation;
  • with a 1×1 pattern, j and k are both 0, so the index is plane either way.

The new fixture is two planes over a 1×2 pattern. Plane 0's blacks are 0 and 40, so its range is
140 - 40 = 100; dividing finds a maximum black of 0 and stretches the range to the full 140,
changing every sample in that plane.

Provenance, and why #495 said its count was a floor

This was missed by the crate's original survey because the shard holding it exited on ENOSPC
after testing 25 of its 82 mutants — the filesystem hit 100% mid-run. Three further shards were
killed by a per-shard timeout that turned out to be too tight for this crate under load.

#495 recorded its 23 survivors as a floor for exactly this reason, and re-running those four shards
under a longer cap (on a machine with disk headroom) turned up this one. The other three re-runs
found only sites already closed there.

Worth recording that the truncation was visible rather than silent: the shard reported a
non-zero exit with an explicit No space left on device. Had it been swallowed, dng would have
been recorded as fully surveyed with a third of that shard untested.

Validation

cargo test -p gamut-dng --all-features, mise run fmt-check, mise run check-tests and clippy
all clean. The mutant was applied by hand and confirmed caught.

`levels.black()[(j * cols + k) * spp + plane]` walks the black-level repeat
pattern to find each plane's largest black, which sets that plane's scale.
Mutating `* spp` to `/ spp` collapses the pattern's cells onto one index, so a
plane's scale is computed from the wrong black.

It went unnoticed because the fixtures covered multiple planes and multiple
cells but never both at once: with one sample per pixel the two operators agree,
and with a 1x1 pattern the index is `plane` either way. The new fixture is two
planes over a 1x2 pattern, where plane 0's blacks are 0 and 40 -- dividing finds
a maximum of 0 and stretches the range from 100 to the full 140.

This one was missed by the crate's own survey and only turned up on a re-run:
its shard had been cut short when the filesystem hit 100%, having tested 25 of
its 82 mutants. Worth recording that the truncation was visible -- the shard
exited non-zero with an explicit ENOSPC -- rather than passing quietly as a clean
result.

Refs #110
@justin13888
justin13888 merged commit 6a75ec4 into master Sep 3, 2026
8 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