Skip to content

Fix reading uninitialized memory in polygonConvexHullCartesian - #127015

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix-convex-hull-empty-exterior
Oct 21, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix-convex-hull-empty-exterior

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

boost::geometry::convex_hull builds the hull only from exterior rings, but checks the input for emptiness with boost::geometry::is_empty, which also looks at interior rings. For a polygon with an empty exterior ring and a non-empty interior ring, it read uninitialized points and returned garbage, e.g. polygonConvexHullCartesian([[[], [(0., 0.), (1., 1.)]]]::MultiPolygon) returned [[(1.258857864326815e-309,2.37e-322),...]], different on every run. MemorySanitizer reported it in the AST fuzzer (STID 1401-309d): https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=629df3319f3cfc7d3adba3f078de4061f9e39399&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_msan%29

Now an empty polygon is returned when there are no exterior ring points.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix polygonConvexHullCartesian returning garbage for a polygon with an empty exterior ring and a non-empty interior ring.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/127015]

Version info

  • Merged into: 26.11.1.384-master (included in 26.11 and later)
  • Backported to: 26.10.2.55, 26.9.24.9, 26.8.33.9, 26.7.38.12, 26.3.58.6

`boost::geometry::convex_hull` builds the hull only from exterior rings,
but checks the input for emptiness with `boost::geometry::is_empty`, which
also looks at interior rings. For a polygon with an empty exterior ring and
a non-empty interior ring it read uninitialized points and returned garbage.
MemorySanitizer reported it in the AST fuzzer (STID 1401-309d).

Return an empty polygon when there are no exterior ring points.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=629df3319f3cfc7d3adba3f078de4061f9e39399&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_msan%29

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fd688ae]

Summary: ✅


AI Review

Summary

The change makes polygonConvexHullCartesian return an empty Polygon when all exterior rings are empty, avoiding Boost's use of uninitialized hull endpoints. No actionable findings. The new regression test covers Polygon, MultiPolygon, mixed empty/nonempty components, and multiple rows; it and the existing convex-hull test passed in Fast test.

Missing context / blind spots
  • ⚠️ Targeted sanitizer and bugfix-validation jobs were pending at review time. No local ClickHouse build was available; completed CI results would close sanitizer runtime verification.
Final Verdict

Status: ✅ Approve. No changes requested.

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-geo Geospatial functions and related libs (e.g., H3, S2, geo distance). labels Oct 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing fd688ae1d with master c7531f5ee (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 12 s compile time in total, 7 of them have a recent master baseline.

Job report

@alexey-milovidov alexey-milovidov added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Oct 20, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Oct 20, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 21, 2026
@alexey-milovidov alexey-milovidov added the blocker This issue / pr blocks a new release label Oct 21, 2026
Merged via the queue into master with commit dec7d79 Oct 21, 2026
179 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-convex-hull-empty-exterior branch October 21, 2026 04:41
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 21, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 21, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 21, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 21, 2026
Backport #127015 to 26.10: Fix reading uninitialized memory in `polygonConvexHullCartesian`
clickhouse-gh Bot added a commit that referenced this pull request Oct 21, 2026
Backport #127015 to 26.9: Fix reading uninitialized memory in `polygonConvexHullCartesian`
clickhouse-gh Bot added a commit that referenced this pull request Oct 21, 2026
Backport #127015 to 26.8: Fix reading uninitialized memory in `polygonConvexHullCartesian`
PedroTadim added a commit that referenced this pull request Oct 21, 2026
Backport #127015 to 26.3: Fix reading uninitialized memory in `polygonConvexHullCartesian`
strtgbb pushed a commit to Altinity/ClickHouse that referenced this pull request Oct 22, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 23, 2026
Backport #127015 to 26.7: Fix reading uninitialized memory in `polygonConvexHullCartesian`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker This issue / pr blocks a new release comp-geo Geospatial functions and related libs (e.g., H3, S2, geo distance). pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants