Skip to content

GH-50971: [C++][Parquet] Fix usage of disparate length types for metadata reading - #50972

Merged
pitrou merged 2 commits into
apache:mainfrom
pitrou:pq-uint32
Aug 25, 2026
Merged

GH-50971: [C++][Parquet] Fix usage of disparate length types for metadata reading#50972
pitrou merged 2 commits into
apache:mainfrom
pitrou:pq-uint32

Conversation

@pitrou

@pitrou pitrou commented Aug 24, 2026

Copy link
Copy Markdown
Member

Rationale for this change

The usage of disparate integer types (int64_t, uint32_t) makes our checks and computations fragile, especially with C++ adding its own integer promotion rules across arithmetic operations.

We have had at least one report (courtesy of Ada Logics and Claude) where a carefully crafted Parquet file can read from an invalid pointer due to arithmetic overflow in the 32-bit domain.

What changes are included in this PR?

Use int64_t throughout most internal APIs and code paths when reading Parquet metadata. Other types such as uint32_t should only be used where necessary when interacting with third-party libraries such as Thrift C++.

Are these changes tested?

By existing tests, and manually using said hand-crafted Parquet file.

Are there any user-facing changes?

Some APIs taking a uint32_t* inout-parameter are deprecated, alternatives taking a int64_t value are available.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #50971 has been automatically assigned in GitHub to PR creator.

@pitrou
pitrou marked this pull request as ready for review August 24, 2026 16:17
@pitrou
pitrou requested a review from wgtmac as a code owner August 24, 2026 16:17
@github-actions github-actions Bot added the awaiting review Awaiting review label Aug 24, 2026
@pitrou

pitrou commented Aug 24, 2026

Copy link
Copy Markdown
Member Author

@HuaHuaY @adamreeve @wgtmac Do you want to take a look?

@adamreeve adamreeve left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks like a good improvement to me thanks @pitrou

Comment thread cpp/src/parquet/thrift_internal.h Outdated
Comment thread cpp/src/parquet/thrift_internal.h Outdated

/// \brief Size of the original thrift encoded metadata footer.
uint32_t size() const;
int64_t size() const;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be considered a breaking change? I think it's probably OK. Any existing consumer code might end up with a narrowing conversion when storing the result of this, or get a different type if they assign to an auto typed variable, but that should work out OK.

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.

I would optimistically say it's ok too. More importantly, I'm not sure anyone but us has a use for this API.

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Aug 24, 2026
@pitrou

pitrou commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

@github-actions crossbow submit -g cpp

@github-actions

Copy link
Copy Markdown
Failed to push updated references, potentially because of credential issues: ['refs/heads/actions-55f0e8bc03-github-test-conda-cpp', 'refs/tags/actions-55f0e8bc03-github-test-conda-cpp', 'refs/heads/actions-55f0e8bc03-github-test-debian-experimental-cpp-gcc-15', 'refs/tags/actions-55f0e8bc03-github-test-debian-experimental-cpp-gcc-15', 'refs/heads/actions-55f0e8bc03-github-test-ubuntu-22.04-cpp-no-threading', 'refs/tags/actions-55f0e8bc03-github-test-ubuntu-22.04-cpp-no-threading', 'refs/heads/actions-55f0e8bc03-github-test-ubuntu-24.04-cpp-bundled-offline', 'refs/tags/actions-55f0e8bc03-github-test-ubuntu-24.04-cpp-bundled-offline', 'refs/heads/actions-55f0e8bc03-github-test-ubuntu-24.04-cpp-minimal-with-formats', 'refs/tags/actions-55f0e8bc03-github-test-ubuntu-24.04-cpp-minimal-with-formats', 'refs/heads/actions-55f0e8bc03-github-test-ubuntu-22.04-cpp-emscripten', 'refs/tags/actions-55f0e8bc03-github-test-ubuntu-22.04-cpp-emscripten', 'refs/heads/actions-55f0e8bc03-github-test-build-cpp-fuzz', 'refs/tags/actions-55f0e8bc03-github-test-build-cpp-fuzz', 'refs/heads/actions-55f0e8bc03-github-example-cpp-minimal-build-static-system-dependency', 'refs/tags/actions-55f0e8bc03-github-example-cpp-minimal-build-static-system-dependency', 'refs/heads/actions-55f0e8bc03-github-test-conda-cpp-valgrind', 'refs/tags/actions-55f0e8bc03-github-test-conda-cpp-valgrind', 'refs/heads/actions-55f0e8bc03-github-test-ubuntu-24.04-cpp-gcc-13-bundled', 'refs/tags/actions-55f0e8bc03-github-test-ubuntu-24.04-cpp-gcc-13-bundled', 'refs/heads/actions-55f0e8bc03-github-test-ubuntu-24.04-cpp-thread-sanitizer', 'refs/tags/actions-55f0e8bc03-github-test-ubuntu-24.04-cpp-thread-sanitizer', 'refs/heads/actions-55f0e8bc03-github-test-ubuntu-22.04-cpp', 'refs/tags/actions-55f0e8bc03-github-test-ubuntu-22.04-cpp', 'refs/heads/actions-55f0e8bc03-github-example-cpp-tutorial', 'refs/tags/actions-55f0e8bc03-github-example-cpp-tutorial', 'refs/heads/actions-55f0e8bc03-github-test-ubuntu-24.04-cpp', 'refs/tags/actions-55f0e8bc03-github-test-ubuntu-24.04-cpp', 'refs/heads/actions-55f0e8bc03-github-example-cpp-minimal-build-static', 'refs/tags/actions-55f0e8bc03-github-example-cpp-minimal-build-static', 'refs/heads/actions-55f0e8bc03-github-test-fedora-42-cpp', 'refs/tags/actions-55f0e8bc03-github-test-fedora-42-cpp', 'refs/heads/actions-55f0e8bc03-github-test-ubuntu-24.04-cpp-gcc-14', 'refs/tags/actions-55f0e8bc03-github-test-ubuntu-24.04-cpp-gcc-14', 'refs/heads/actions-55f0e8bc03-github-test-ubuntu-22.04-cpp-bundled', 'refs/tags/actions-55f0e8bc03-github-test-ubuntu-22.04-cpp-bundled', 'refs/heads/actions-55f0e8bc03-github-test-debian-13-cpp-i386', 'refs/tags/actions-55f0e8bc03-github-test-debian-13-cpp-i386', 'refs/heads/actions-55f0e8bc03-github-test-debian-13-cpp-amd64', 'refs/tags/actions-55f0e8bc03-github-test-debian-13-cpp-amd64', 'refs/heads/actions-55f0e8bc03']
The Archery job run can be found at: https://github.com/apache/arrow/actions/runs/32819311767

@pitrou

pitrou commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

It seems like the Crossbow comment bot is broken at the moment. @raulcd @kou ^^

@pitrou
pitrou merged commit f2a446b into apache:main Aug 25, 2026
53 of 55 checks passed
@pitrou pitrou removed the awaiting committer review Awaiting committer review label Aug 25, 2026
@pitrou
pitrou deleted the pq-uint32 branch August 25, 2026 07:33
@raulcd

raulcd commented Aug 25, 2026

Copy link
Copy Markdown
Member

@rok we might require to update the token? I'm off but I can try and generate and add a new token later today

@rok

rok commented Aug 25, 2026

Copy link
Copy Markdown
Member

Most likely. I'll put mine in for now to check.

@rok

rok commented Aug 25, 2026

Copy link
Copy Markdown
Member

@github-actions crossbow submit -g cpp

@github-actions

Copy link
Copy Markdown

Revision: 671358f

Submitted crossbow builds: ursacomputing/crossbow @ actions-4821e33666

Task Status
example-cpp-minimal-build-static GitHub Actions
example-cpp-minimal-build-static-system-dependency GitHub Actions
example-cpp-tutorial GitHub Actions
test-build-cpp-fuzz GitHub Actions
test-conda-cpp GitHub Actions
test-conda-cpp-valgrind GitHub Actions
test-debian-13-cpp-amd64 GitHub Actions
test-debian-13-cpp-i386 GitHub Actions
test-debian-experimental-cpp-gcc-15 GitHub Actions
test-fedora-42-cpp GitHub Actions
test-ubuntu-22.04-cpp GitHub Actions
test-ubuntu-22.04-cpp-bundled GitHub Actions
test-ubuntu-22.04-cpp-emscripten GitHub Actions
test-ubuntu-22.04-cpp-no-threading GitHub Actions
test-ubuntu-24.04-cpp GitHub Actions
test-ubuntu-24.04-cpp-bundled-offline GitHub Actions
test-ubuntu-24.04-cpp-gcc-13-bundled GitHub Actions
test-ubuntu-24.04-cpp-gcc-14 GitHub Actions
test-ubuntu-24.04-cpp-minimal-with-formats GitHub Actions
test-ubuntu-24.04-cpp-thread-sanitizer GitHub Actions

@rok

rok commented Aug 25, 2026

Copy link
Copy Markdown
Member

@pitrou I've temporarily replaced CROSSBOW_GITHUB_TOKEN with mine until @kou or @raulcd put in theirs. Crossbow comment bot should be back. Please report if there are other crossbow features failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants