birkskyum opened a new issue, #12472:
URL: https://github.com/apache/arrow-rs/issues/12472
### 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
```rust
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.
--
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]