Skip to content

Conversation

rambleraptor
Copy link
Contributor

Rationale for this change

We've caused some unexpected panics from our internal testing. We've put in error checks for all of these so that they don't affect other users.

What changes are included in this PR?

Various error checks to ensure panics don't occur.

Are these changes tested?

Tests should continue to pass.

If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
Existing tests should cover these changes.

Are there any user-facing changes?

None.

@github-actions github-actions bot added the parquet Changes to the parquet crate label Oct 13, 2025
@etseidl
Copy link
Contributor

etseidl commented Oct 14, 2025

I guess we can lump this in with #7806

@rambleraptor
Copy link
Contributor Author

I'm happy to split this up into some separate PRs. I know it's a lot of random things as-is.

@etseidl
Copy link
Contributor

etseidl commented Oct 14, 2025

I'm happy to split this up into some separate PRs. I know it's a lot of random things as-is.

The pedant in me wants to take you up on your offer, but there's not so much going on here that I think that's necessary. Maybe just change the title to something that sounds better 😉. ("Address panics found in external testing").

Copy link
Contributor

@etseidl etseidl left a comment

Choose a reason for hiding this comment

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

Thanks @rambleraptor, these all look sensible to me.

Would it be possible to gin up some tests for at least some of them?

Copy link
Contributor

@scovich scovich left a comment

Choose a reason for hiding this comment

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

Thanks for digging into this! Several comments.

return Ok((end, buf.slice(i32_size..end)));
}
}
Err(general_err!("not enough data to read levels"))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is definitely an improvement over the existing code, but it opens a question:

Given that we're reading bytes from a byte buffer, it seems like we must expect to hit this situation at least occasionally? And the correct response is to fetch more bytes, not fail? Is there some mechanism for handling that higher up in the call stack? Or is there some reason it should be impossible for this code to run off the end of the buffer?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also -- it seems like read_num_bytes should do bounds checking internally and return Option<T>, so buffer overrun is obvious at the call site instead of a hidden panic footgun? The method has a half dozen other callers, and they all need to do manual bounds checking, in various ways and with varying degrees of safety. In particular, parquet/src/data_type.rs has two call sites that lack any visible bounds checks.

Copy link
Contributor

Choose a reason for hiding this comment

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

In this particular instance we're reading a buffer that should contain an entire page of data. If it doesn't, that likely points to a problem with the metadata.

Changes to read_num_bytes would likely need more careful consideration as I suspect it might be used in some performance critical sections.

} else if !is_root_node {
return Err(general_err!("Repetition level must be defined for non-root types"));
}
Ok((next_index, Arc::new(builder.build().unwrap())))
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we know the unwrap is safe?

Copy link
Contributor

Choose a reason for hiding this comment

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

build never returns an Err 😉. But good point, could replace unwrap with ?.

@rambleraptor rambleraptor changed the title Assorted panics we've found Address panics found in external testing Oct 14, 2025
@alamb alamb changed the title Address panics found in external testing Change some panics to errors in parquet decoder Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants