linyiru opened a new issue, #12498:
URL: https://github.com/apache/arrow-rs/issues/12498
### Describe the bug
Reading a `FIXED_LEN_BYTE_ARRAY` column through the Arrow reader panics if a
data page is `RLE_DICTIONARY` / `PLAIN_DICTIONARY` encoded and the column chunk
has no dictionary page:
```
thread 'main' panicked at
parquet/src/arrow/array_reader/fixed_len_byte_array.rs:444:52:
called `Option::unwrap()` on a `None` value
```
The byte array readers return `missing dictionary page for column` for the
same input (`byte_array.rs:316`, `byte_array_dictionary.rs:472`).
Found by byte-flip fuzzing: 28 of 800,000 reads of mutated files hit this
site.
### To Reproduce
```rust
use std::sync::Arc;
use arrow::array::{ArrayRef, FixedSizeBinaryArray, RecordBatch};
use bytes::Bytes;
use parquet::arrow::arrow_reader::ParquetRecordBatchReaderBuilder;
use parquet::arrow::ArrowWriter;
fn main() {
// One dictionary-encoded FIXED_LEN_BYTE_ARRAY(4) column
let values =
FixedSizeBinaryArray::try_from_iter([b"aaaa", b"bbbb",
b"aaaa"].into_iter()).unwrap();
let batch = RecordBatch::try_from_iter([("f", Arc::new(values) as
ArrayRef)]).unwrap();
let mut file = Vec::new();
let mut writer = ArrowWriter::try_new(&mut file, batch.schema(),
None).unwrap();
writer.write(&batch).unwrap();
writer.close().unwrap();
// Turn the dictionary page into an INDEX_PAGE, which readers skip. The
page
// header starts with field 1 (type) = zigzag(DICTIONARY_PAGE = 2) = 4.
let builder =
ParquetRecordBatchReaderBuilder::try_new(Bytes::from(file.clone())).unwrap();
let column = builder.metadata().row_group(0).column(0);
let dict_offset = column.dictionary_page_offset().unwrap() as usize;
assert_eq!(file[dict_offset..dict_offset + 2], [0x15, 0x04]);
file[dict_offset + 1] = 0x02; // zigzag(INDEX_PAGE = 1)
let reader = ParquetRecordBatchReaderBuilder::try_new(Bytes::from(file))
.unwrap()
.build()
.unwrap();
for batch in reader {
println!("{:?}", batch.map(|b| b.num_rows()));
}
}
```
Panics on 60.2.0 and on main (d470f2d54).
### Expected behavior
`Err(ParquetError("missing dictionary page for column"))`.
### Additional context
This is the Arrow-side counterpart of #12129 (`Decoder for dict should have
been set` in `column/reader/decoder.rs`); #12189 does not touch
`fixed_len_byte_array.rs`.
This report was prepared with AI assistance (Claude Code). The reproduction
was run against 60.2.0 and main.
### Willingness to contribute
I plan to contribute a fix for this bug independently
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]