Skip to content

Cherry pick #116583 to 26.3: Fix h3Line returning uninitialized memory when the line crosses pentagon distortion - #118555

Merged
PedroTadim merged 3 commits into
backport/26.3/116583from
cherrypick/26.3/116583
Sep 7, 2026
Merged

PedroTadim merged 3 commits into
backport/26.3/116583from
cherrypick/26.3/116583

Conversation

@robot-clickhouse-ci-1

Copy link
Copy Markdown
Contributor

Original pull-request #116583

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 2 commits August 26, 2026 18:48
h3Line builds its result in two passes. The sizing pass calls
gridPathCellsSize and checks its H3Error, the result is then sized with
PODArray::resize, which does not initialize elements, and the fill pass
called gridPathCells and discarded the returned H3Error.

The two passes do not validate the same thing. gridPathCellsSize
validates only the two endpoints, while gridPathCells walks the
intermediate cells and returns E_PENTAGON after a partial write when the
line crosses pentagon distortion. The slots it never reached were
returned to the client, so

  SELECT h3Line(toUInt64(585609238802333695), toUInt64(585624631965122559))

handed back a 3-element array whose third element was raw heap. The
observed values were live heap addresses that varied between calls, and a
plain SELECT with constant arguments is enough to reach it.

Check the error, matching the sizing pass in the same function and the
sibling h3HexRing, which has the identical two-pass shape and already
checks it. h3Line and h3HexRing are the only two h3 functions that fill a
resize()d PODArray this way, so the whole class now checks.

The new arm in 04034_h3_functions_default_if_invalid pins that this also
throws under functions_h3_default_if_invalid = 1: that setting
substitutes a default for an invalid cell, and both endpoints here are
valid.

Co-Authored-By: Claude Opus 5 <[email protected]>
…ory-pentagon

Fix `h3Line` returning uninitialized memory when the line crosses pentagon distortion
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants