parquet: a deeply nested schema overflows the stack
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Start at ParquetMetaDataReader::decode_metadata in the parquet crate, where the footer schema is decoded, and add a depth check there. The recursive walks to check are schema_from_array_helper in schema/types.rs near line 1533 and ArrayReaderBuilder::build_reader in arrow/array_reader/builder.rs near line 192. Done when the reproducer in the issue returns an Err on a 2 MiB thread instead of overflowing the stack.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
Schema depth isn't bounded, and the schema is walked by recursion. A footer of 3,000 nested groups (24 KB) overflows a 2 MiB stack in schema_from_array_helper (schema/types.rs:1533). 2 MiB is the stack of a std::thread::spawn thread or a tokio worker. ArrayReaderBuilder::build_reader (arrow/array_reader/builder.rs:192) uses more stack per level, so building a ParquetRecordBatchReader overflows at about 310 levels (2.5 KB) in a release build. A stack overflow aborts the process. This happens on 60.1.0, 60.2.0 and main (8befa3cd89).
To Reproduce
use parquet::file::metadata::ParquetMetaDataReader;
fn main() {
// A footer of 3,000 nested optional groups around one INT32 leaf
let mut f = vec![0x15, 0x02, 0x19, 0xfc, 0xba, 0x17];
f.extend_from_slice(b"\x48\x06schema\x15\x02\x00");
for _ in 0..3000 {
f.extend_from_slice(b"\x35\x02\x18\x01g\x15\x02\x00");
}
f.extend_from_slice(b"\x15\x02\x25\x02\x18\x01x\x00\x16\x00\x19\x0c\x00");
// std::thread::spawn gives a 2 MiB stack, like tokio's workers
let r = std::thread::spawn(move || ParquetMetaDataReader::decode_metadata(&f).map(|_| ()));
println!("{:?}", r.join().unwrap());
}
Expected behavior
An Err. A depth limit checked while the footer is decoded would bound every later recursive walk. With an 8 MiB stack the same footer decodes to Ok(()), so only its depth is at fault.
Additional context
#12142 bounded the footer's num_children reservation (#11954), and depth is the footer's remaining unbounded walk.
- 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
-
[BUG] kaku 默认 git alias 为 g 的问题。Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
clipy-recorder/clipy#695 ·
Los mantenedores suelen responder en 1 día
-
TypeScript BM25 drops supplementary characters at the token length limitPosiblemente ocupada @ErenAta16 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
chroma-core/chroma#8038 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
ESP32: backport #6488 (torn LACT counter read in `time::implem::raw_counter`) to esp-hal 1.2.xAbiertobug jury chip:esp32
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día