parquet: `skip_records` loops forever when a page has fewer repetition levels than it declares
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 30/100
調査の方向性
Start at parquet/src/column/reader.rs:312 in skip_records and compare its repetition-level handling with the check in read_records at lines 248-253. Reproduce the malformed page using the provided example and confirm skipping returns the same insufficient-levels error as reading. An open pull request (#12500) is already linked to this issue.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
GenericColumnReader::skip_records does not terminate when a data page of a repeated column declares more values than it has repetition levels. Once the level decoder is exhausted, skip_rep_levels returns (0, 0), nothing in the loop body advances, and while remaining_records != 0 spins at 100% CPU.
read_records handles the same page with an error (Insufficient repetition levels read from column), added in #6232. The skip path did not get the same check.
Through the Arrow reader this is reached by with_offset, with_row_selection and row filters on any list column. A single flipped byte is enough: a byte-flip fuzz of 9 small files (4,000 mutations each, read with with_offset(1)) hung 6 times.
To Reproduce
use std::sync::Arc;
use bytes::Bytes;
use parquet::basic::{Encoding, Repetition, Type as PhysicalType};
use parquet::column::page::{Page, PageMetadata, PageReader};
use parquet::column::reader::{get_column_reader, get_typed_column_reader};
use parquet::data_type::Int32Type;
use parquet::errors::Result;
use parquet::schema::types::{ColumnDescriptor, ColumnPath, Type};
struct OnePage(Option<Page>);
impl Iterator for OnePage {
type Item = Result<Page>;
fn next(&mut self) -> Option<Self::Item> {
self.get_next_page().transpose()
}
}
impl PageReader for OnePage {
fn get_next_page(&mut self) -> Result<Option<Page>> {
Ok(self.0.take())
}
fn peek_next_page(&mut self) -> Result<Option<PageMetadata>> {
Ok(self.0.as_ref().map(|_| PageMetadata {
num_rows: None,
num_levels: Some(4),
is_dict: false,
}))
}
fn skip_next_page(&mut self) -> Result<()> {
self.0 = None;
Ok(())
}
}
fn main() {
// list<int32> element column: max definition level 1, max repetition level 1
let leaf = Type::primitive_type_builder("element", PhysicalType::INT32)
.with_repetition(Repetition::REQUIRED)
.build()
.unwrap();
let path = ColumnPath::new(vec!["list".to_string(), "element".to_string()]);
let descr = Arc::new(ColumnDescriptor::new(Arc::new(leaf), 1, 1, path));
// The page declares 4 values, but its repetition levels are one RLE run of 2.
let page = || {
let rep_levels = [2 << 1, 0];
let def_levels = [4 << 1, 1];
let mut buf = Vec::new();
buf.extend_from_slice(&rep_levels);
buf.extend_from_slice(&def_levels);
buf.extend([10_i32, 20, 30, 40].iter().flat_map(|v| v.to_le_bytes()));
Page::DataPageV2 {
buf: Bytes::from(buf),
num_values: 4,
encoding: Encoding::PLAIN,
num_nulls: 0,
num_rows: 4,
def_levels_byte_len: 2,
rep_levels_byte_len: 2,
is_compressed: false,
statistics: None,
}
};
let reader = || {
let pages = Box::new(OnePage(Some(page())));
get_typed_column_reader::<Int32Type>(get_column_reader(descr.clone(), pages))
};
let (mut values, mut def, mut rep) = (vec![], vec![], vec![]);
let read = reader().read_records(3, Some(&mut def), Some(&mut rep), &mut values);
println!("read_records(3): {read:?}");
println!("skip_records(3): ...");
let skipped = reader().skip_records(3); // never returns
println!("skip_records(3): {skipped:?}");
}
Output on 60.2.0 and on main (d470f2d54):
read_records(3): Err(General("Insufficient repetition levels read from column"))
skip_records(3): ...
and the process has to be killed.
Expected behavior
skip_records returns the same error as read_records.
Additional context
parquet/src/column/reader.rs:312(skip_records), compare the check at lines 248-253 inread_records.- Same class as #1997 and #6232 (#6228), which fixed the read path.
- Per SECURITY.md this is a bug rather than a vulnerability (an infinite loop on malformed input).
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
- 主要言語
- Rust
- スター
- 3.7k
- フォーク
- 1.5k
- 平均マージ
- 2日 16時間
- マージ済み PR(30日)
- 183
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/arrow-rs のほかの issue
-
parquet: `ArrowWriter::try_new` panics on a schema with a Union field instead of returning an errorオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
`RunArray::try_new` rejects run ends whose null buffer has no nulls対応中かも @Surajsuthar が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/arrow-rs#12427 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Variant] `variant_get` string and binary cast errors show Rust builder type names再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 61/100
メンテナーはふだん 1 日以内に返信
apache/arrow-rs の issue をすべて見る
似ている issue
-
area:ui effort:medium enhancement P7 source:agent
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
marketing
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
machine rename accepts a label already used by another machine, making --machine <label> ambiguousオープンmaintainer-needed p2 remote triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug help wanted ui
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
userFRM/egui-charts#4605 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信