Skip to content

fix: don't panic on malformed struct field dtypes - #9742

Open
jackylee-ch wants to merge 1 commit into
vortex-data:developfrom
jackylee-ch:structfields-validate-dtypes
Open

fix: don't panic on malformed struct field dtypes#9742
jackylee-ch wants to merge 1 commit into
vortex-data:developfrom
jackylee-ch:structfields-validate-dtypes

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

Opening a crafted file whose struct has a field with an undecodable dtype panicked instead of
erroring. Field dtypes decode lazily, so the top-level dtype segment parsed cleanly and the panic
fired later, in StructFields::fields() while reading the file-statistics footer.

The decoding accessors return a plain DType, and FieldDType's PartialEq/Hash are trait
methods — no signature there can carry a failure. So the check goes where the fields are built from a
flatbuffer: try_from_fields decodes each one, and deserialization now goes through it.
UnionVariants had the identical shape and gets the same check. The cost is one decode per field at
open time, which buys the accessors staying infallible.

Tests

Both new tests build a child dtype that passes the flatbuffer verifier but cannot decode; removing
either check makes both fail. cargo test -p vortex-array goes 3442 → 3444, same two pre-existing
arrays::listview failures.

AI assistance

Written with agentic AI assistance; I confirmed the checks fail when removed.

Opening a crafted file whose struct has a field with an undecodable dtype
panicked instead of erroring. Field dtypes are decoded lazily, so the
top-level dtype segment parsed cleanly and the panic fired later, in
StructFields::fields() while reading the file-statistics footer.

The accessors that decode a field dtype return a plain DType, and the
PartialEq and Hash impls on FieldDType are trait methods, so no signature
there can carry a failure. The check therefore belongs where the fields are
built from a flatbuffer: try_from_fields decodes each field dtype, and
deserialization goes through it. UnionVariants had the identical shape and
gets the same check.

This costs one decode per field at open time, which is the price of the
accessors staying infallible.

Signed-off-by: jackylee <qcsd2011@gmail.com>
@joseph-isaacs

Copy link
Copy Markdown
Contributor

these comments are very odd?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants