thisisnic opened a new issue, #55712:
URL: https://github.com/apache/arrow/issues/55712
### Describe the bug, including details regarding any error messages,
version, and platform.
`parquet::arrow::FileReader::ReadColumn(int i)` takes the index of a
top-level schema field, but its bounds check compares `i` against the number of
Parquet leaf columns. When a file has nested columns there are more leaf
columns than fields, so an index between the two counts passes the check and
then indexes past the end of `manifest_.schema_fields`.
In `cpp/src/parquet/arrow/reader.cc`, `FileReaderImpl::GetColumn()` calls
`BoundsCheckColumn(i)`, which checks `i` against `num_columns()` (the leaf
count), and then reads `manifest_.schema_fields[i]`. `GetFieldReader()` in the
same file checks against `manifest_.schema_fields.size()` instead, which is the
check `GetColumn()` needs.
Reprex from R, where it crashes the session. The file has 3 fields and 4
leaf columns. `$ReadColumn(i)` in R subtracts 1 before calling C++, so
`ReadColumn(4)` calls C++ `ReadColumn(3)`:
```r
library(arrow)
df <- tibble::tibble(
a = 1:2,
s = tibble::tibble(x = 1:2, y = c("p", "q")),
b = c("u", "v")
)
tf <- tempfile(fileext = ".parquet")
write_parquet(df, tf)
pq <- ParquetFileReader$create(tf)
pq$num_columns
#> [1] 4
pq$ReadColumn(3)$type
#> Utf8
#> string
pq$ReadColumn(4)
#>
#> *** caught segfault ***
#> address 0x79, cause 'memory not mapped'
#>
#> Traceback:
#> 1: parquet___arrow___FileReader__ReadColumn(self, i)
#> 2: pq$ReadColumn(4)
#> An irrecoverable exception occurred. R is aborting now ...
```
Expected: an "index out of bounds" error, as there are only 3 fields.
Reproduced with arrow 26.0.0 and with 26.0.1.9000 built from main, on Linux.
This issue was written with AI assistance (Claude) and reviewed by me before
posting.
### Component(s)
C++, Parquet, R
--
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]