Skip to content

TASImage::DrawEllips2: Flood fill leaks through contour gap in asim_straight_ellips() (affects up to 64% of axis-aligned non-circular ellipses) #23148

Description

@tekinertekin

Check duplicate issues.

  • Checked for duplicates

Description

When TASImage::DrawEllips2 is called filled, the fill breaches the contour and floods the entire image. The issue lies in asim_straight_ellips(); asim_ellips2 redirects 0/90/180° to it (draw.c:1465 and 1472; rx/ry are swapped at 90°). Across 1,769 tested (rx, ry) pairs, 1,136 leak at 0° and 180° (64%), 187 leak at 90°, and 22 leak at 45°/135°. Circles are completely unaffected across all angles, which is why existing tests fail to catch it. Mechanism: two arcs fail to connect at the tip, causing coverage in the central column to fall below the wall threshold of 140 (where pixels with coverage $\le 140$ are filled), allowing asim_flood_fill to leak through (e.g., dropping to values between 2 and 71 near the tip). There is no simple ratio threshold: rx=8, ry=7 (ratio 1.14) leaks, while rx=30, ry=20 (1.50) stays intact. Ordinary ellipses like 40×30 are also affected, meaning the bug is not limited to extreme aspect ratios.

Reproducer

cc -O2 -I builtins/libAfterImage -o repro root-ellipse-repro.c builtins/libAfterImage/draw.c -lm
./repro

root-ellipse-repro.c

ROOT version

Tested on master branch at commit 82a44f9. Note: Measurements were conducted directly on the standalone vendored libAfterImage without building full CERN ROOT.

Installation method

source checkout

Operating system

macOS, arm64 (Apple Silicon)

Additional context

At 45°/135°, a small residual leak rate of 1.2% (22 out of 1,769 pairs) remains—this is from the angled path patched in #23133. While not fully eliminated, the remaining issue on that path is significantly smaller in scope compared to the axis-aligned leak.

Note: The reproducer script, automated sweeps, and initial root-cause analysis were generated using Claude Opus 5. The report text was written and fact-checked by the author.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions