parquet: `skip_records` loops forever when a page has fewer repetition levels than it declares
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 30/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Rust
- Estrellas
- 3.7k
- Forks
- 1.5k
- Merge medio
- 2 d 16 h
- PR fusionados (30 d)
- 183
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/arrow-rs
-
parquet: `ArrowWriter::try_new` panics on a schema with a Union field instead of returning an errorAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
`RunArray::try_new` rejects run ends whose null buffer has no nullsPosiblemente ocupada @Surajsuthar la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
apache/arrow-rs#12427 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Variant] `variant_get` string and binary cast errors show Rust builder type namesQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 61/100
Los mantenedores suelen responder en 1 día
Todos los issues de apache/arrow-rs
Issues similares
-
area:ui effort:medium enhancement P7 source:agent
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
marketing
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
machine rename accepts a label already used by another machine, making --machine <label> ambiguousAbiertomaintainer-needed p2 remote triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
bug help wanted ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
userFRM/egui-charts#4605 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día