Skip to content

Fix potential malformed headers in parquet delta decoder - #22275

Merged
rapids-bot[bot] merged 6 commits into
NVIDIA:release/26.06from
mhaseeb123:fix/potential-errors-part-02
May 15, 2026
Merged

Fix potential malformed headers in parquet delta decoder#22275
rapids-bot[bot] merged 6 commits into
NVIDIA:release/26.06from
mhaseeb123:fix/potential-errors-part-02

Conversation

@mhaseeb123

@mhaseeb123 mhaseeb123 commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Description

This PR checks for potential malformed headers in Parquet delta decoder and propagates it in decoders.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented Apr 23, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@mhaseeb123 mhaseeb123 changed the title Check potential malformed headers in parquet delta decoder 🚧 Check potential malformed headers in parquet delta decoder Apr 23, 2026
@github-actions github-actions Bot added the libcudf Affects libcudf (C++/CUDA) code. label Apr 23, 2026
@mhaseeb123 mhaseeb123 changed the title 🚧 Check potential malformed headers in parquet delta decoder 🚧 Fix potential malformed headers in parquet delta decoder Apr 23, 2026
@mhaseeb123 mhaseeb123 changed the title 🚧 Fix potential malformed headers in parquet delta decoder Fix potential malformed headers in parquet delta decoder Apr 24, 2026
Comment thread cpp/src/io/parquet/delta_binary.cuh Outdated
Comment thread cpp/src/io/parquet/page_delta_decode.cu Outdated
Comment thread cpp/src/io/parquet/delta_binary.cuh Outdated
@mhaseeb123
mhaseeb123 marked this pull request as ready for review April 24, 2026 20:02
@mhaseeb123
mhaseeb123 requested a review from a team as a code owner April 24, 2026 20:02
@mhaseeb123 mhaseeb123 added bug Something isn't working 3 - Ready for Review Ready for review by team cuIO cuIO issue non-breaking Non-breaking change labels Apr 24, 2026
Comment thread cpp/src/io/parquet/page_delta_decode.cu Outdated
Comment thread cpp/src/io/parquet/page_delta_decode.cu Outdated
Comment on lines 389 to 392
uint32_t const prev_src_pos = s->src_pos;

uint32_t target_pos;
uint32_t const src_pos = s->src_pos;

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.

src_pos and prev_src_pos play identical roles.

Comment thread cpp/src/io/parquet/page_delta_decode.cu Outdated
@mhaseeb123
mhaseeb123 marked this pull request as draft April 29, 2026 21:21
@GregoryKimball GregoryKimball moved this to Burndown in libcudf May 4, 2026
if (batch_size > max_delta_mini_block_size) {
set_error(static_cast<kernel_error::value_type>(decode_error::DELTA_PARAMS_UNSUPPORTED),
error_code);
if (block.thread_rank() == 0) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only one thread needs to set the error

@mhaseeb123
mhaseeb123 marked this pull request as ready for review May 14, 2026 21:38
@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e61079d5-4b07-4ace-87d4-e563b75ae7fb

📥 Commits

Reviewing files that changed from the base of the PR and between a50d9de and c839f1b.

📒 Files selected for processing (2)
  • cpp/src/io/parquet/delta_binary.cuh
  • cpp/src/io/parquet/page_delta_decode.cu
🚧 Files skipped from review as they are similar to previous changes (2)
  • cpp/src/io/parquet/delta_binary.cuh
  • cpp/src/io/parquet/page_delta_decode.cu

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Strengthened validation of DELTA_BINARY_PACKED data to detect invalid headers earlier
    • Tightened delta-decoding paths to fail fast on detected header or size errors, avoiding wasted work
    • Improved error reporting and guarded error reporting to ensure clearer, single-point failure notifications

Walkthrough

Adds an error flag to the Parquet delta decoder and validates DELTA_BINARY_PACKED header invariants in init_binary_block. On malformed headers the decoder is moved to an inert state. Three CUDA decoding kernels now check this flag and propagate a DELTA_PARAMS_UNSUPPORTED error from thread 0 when present.

Changes

Delta decoder error handling

Layer / File(s) Summary
Decoder error state and header validation
cpp/src/io/parquet/delta_binary.cuh
Adds bool error to delta_binary_decoder. init_binary_block initializes error = false, validates mini_block_count and block_size (nonzero and divisible), and on failure sets error = true, zeroes/neutralizes decoding counters (value_count, values_per_mb = 1) and advances internal pointers to d_end, then returns. On success computes values_per_mb = block_size / mini_block_count.
Delta binary kernel: sanity and error propagation
cpp/src/io/parquet/page_delta_decode.cu (decode_delta_binary_kernel)
After decoder init, treats db->error as unsupported params alongside batch_size > max_delta_mini_block_size; sets DELTA_PARAMS_UNSUPPORTED via set_error only when block.thread_rank() == 0 and returns early.
Delta byte-array kernel: prefix/suffix decoder checks
cpp/src/io/parquet/page_delta_decode.cu (decode_delta_byte_array_kernel)
Adds early return if prefix_db->error or suffix_db->error, setting DELTA_PARAMS_UNSUPPORTED only from block.thread_rank() == 0. Also guards the existing batch_size > max_delta_mini_block_size error path so set_error runs only on thread 0.
Delta length byte-array kernel: extended sanity check
cpp/src/io/parquet/page_delta_decode.cu (decode_delta_length_byte_array_kernel)
Extends initial sanity check to include db->error with batch_size check; sets DELTA_PARAMS_UNSUPPORTED only for block.thread_rank() == 0 before returning. Moves leaf_level_index declaration to after this check.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • wence-
  • vuule
  • pmattione-nvidia
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: adding header validation checks to the parquet delta decoder to handle malformed headers.
Description check ✅ Passed The PR description is directly related to the changeset, explaining that it checks for malformed headers in the Parquet delta decoder and propagates errors through decoders.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
cpp/src/io/parquet/page_delta_decode.cu (1)

775-781: 💤 Low value

Consider using kernel_error::value_type for consistency with other kernels.

The other delta decode kernels use static_cast<kernel_error::value_type>(...) (e.g., lines 371, 554, 577), while this one uses static_cast<int32_t>(...). The code works correctly, but using the typedef ensures consistency and avoids issues if the type changes.

Suggested fix
  if (db->error) {
    if (block.thread_rank() == 0) {
-      set_error(static_cast<int32_t>(decode_error::DELTA_PARAMS_UNSUPPORTED), error_code);
+      set_error(static_cast<kernel_error::value_type>(decode_error::DELTA_PARAMS_UNSUPPORTED), error_code);
    }
    return;
  }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cpp/src/io/parquet/page_delta_decode.cu` around lines 775 - 781, Replace the
inconsistent cast in the error path: when calling set_error(.., error_code) in
the block where db->error is checked, change the
static_cast<int32_t>(decode_error::DELTA_PARAMS_UNSUPPORTED) to
static_cast<kernel_error::value_type>(decode_error::DELTA_PARAMS_UNSUPPORTED) so
it matches other delta decode kernels (see other uses of
kernel_error::value_type) and keeps type consistency for set_error, using the
same symbols db->error, block.thread_rank(), set_error,
decode_error::DELTA_PARAMS_UNSUPPORTED, and error_code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cpp/src/io/parquet/page_delta_decode.cu`:
- Around line 775-781: Replace the inconsistent cast in the error path: when
calling set_error(.., error_code) in the block where db->error is checked,
change the static_cast<int32_t>(decode_error::DELTA_PARAMS_UNSUPPORTED) to
static_cast<kernel_error::value_type>(decode_error::DELTA_PARAMS_UNSUPPORTED) so
it matches other delta decode kernels (see other uses of
kernel_error::value_type) and keeps type consistency for set_error, using the
same symbols db->error, block.thread_rank(), set_error,
decode_error::DELTA_PARAMS_UNSUPPORTED, and error_code.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8aa79831-7a08-4539-a7ed-f2c3779e2ab2

📥 Commits

Reviewing files that changed from the base of the PR and between d7c7891 and 45e7d15.

📒 Files selected for processing (2)
  • cpp/src/io/parquet/delta_binary.cuh
  • cpp/src/io/parquet/page_delta_decode.cu

values_per_mb = block_size / mini_block_count;
error = false;

// Validate header against the DELTA_BINARY_PACKED spec invariants

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Validate header here and set error field.

if (batch_size > max_delta_mini_block_size) {
set_error(static_cast<kernel_error::value_type>(decode_error::DELTA_PARAMS_UNSUPPORTED),
error_code);
if (db->error or batch_size > max_delta_mini_block_size) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Check for db->error field, propagate it and exit early.

block.sync();

// Propagate malformed-header errors from either underlying DELTA_BINARY_PACKED decoder.
if (prefix_db->error or suffix_db->error) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same everywhere

@mhaseeb123

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

@mhaseeb123 mhaseeb123 added 4 - Needs Review Waiting for reviewer to review or respond and removed 3 - Ready for Review Ready for review by team labels May 14, 2026
@mhaseeb123
mhaseeb123 force-pushed the fix/potential-errors-part-02 branch from c2a5a33 to c839f1b Compare May 15, 2026 21:25
@copy-pr-bot

copy-pr-bot Bot commented May 15, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@mhaseeb123
mhaseeb123 changed the base branch from main to release/26.06 May 15, 2026 21:25
@mhaseeb123

Copy link
Copy Markdown
Contributor Author

/ok to test c839f1b

@mhaseeb123

Copy link
Copy Markdown
Contributor Author

/merge

@ttnghia ttnghia 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.

I would expect this increase register usage a little bit.

@rapids-bot
rapids-bot Bot merged commit 3ae4319 into NVIDIA:release/26.06 May 15, 2026
119 checks passed
@mhaseeb123
mhaseeb123 deleted the fix/potential-errors-part-02 branch May 15, 2026 22:32
@mhaseeb123 mhaseeb123 moved this from Burndown to Landed in libcudf May 15, 2026
madsbk pushed a commit to madsbk/cudf that referenced this pull request May 19, 2026
This PR checks for potential malformed headers in Parquet delta decoder and propagates it in decoders.

Authors:
  - Muhammad Haseeb (https://github.com/mhaseeb123)

Approvers:
  - Paul Mattione (https://github.com/pmattione-nvidia)
  - Bradley Dice (https://github.com/bdice)
  - Nghia Truong (https://github.com/ttnghia)

URL: NVIDIA#22275
@mhaseeb123 mhaseeb123 added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 4 - Needs Review Waiting for reviewer to review or respond labels May 19, 2026
@GregoryKimball GregoryKimball removed this from libcudf Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to Merge Testing and reviews complete, ready to merge bug Something isn't working cuIO cuIO issue libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants