mutexed opened a new issue, #39964:
URL: https://github.com/apache/arrow/issues/39964

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   Hello, I'm trying to use arrow package for reading parquet files. I'm 
building arrow for myself using clang 16 without mimalloc or jemalloc, only 
system memory pool. Arrow version is 15.0.0.
   
   The code of reading file is same as in 
[docs](https://arrow.apache.org/docs/cpp/parquet.html#filereader) with 
arrow::RecordBatchReader:
   ```c++
   arrow::Result<std::shared_ptr<arrow::RecordBatchReader>> 
GetParquetReader(const std::string& location, const int64_t batch_size, 
arrow::MemoryPool* pool) {
       arrow::Status st;
   
       std::shared_ptr<arrow::io::RandomAccessFile> input;
       ARROW_ASSIGN_OR_RAISE(input, arrow::io::ReadableFile::Open(location));
   
       auto arrow_reader_props = parquet::ArrowReaderProperties();
       arrow_reader_props.set_batch_size(batch_size);
       arrow_reader_props.set_pre_buffer(true);
   
       parquet::arrow::FileReaderBuilder reader_builder;
       ARROW_RETURN_NOT_OK(reader_builder.Open(input));
   
       reader_builder.memory_pool(pool);
       reader_builder.properties(arrow_reader_props);
   
       std::unique_ptr<parquet::arrow::FileReader> arrow_reader;
       ARROW_RETURN_NOT_OK(reader_builder.Build(&arrow_reader));
   
       std::shared_ptr<arrow::RecordBatchReader> rb_reader;
       ARROW_RETURN_NOT_OK(arrow_reader->GetRecordBatchReader(&rb_reader));
   
       return 
arrow::Result<std::shared_ptr<arrow::RecordBatchReader>>(rb_reader);
   }
   ```
   
   Then I'm trying to iterate over all batches also like in docs:
   ```c++
   for (arrow::Result<std::shared_ptr<arrow::RecordBatch>> maybe_batch : 
*rb_reader) {
     // Operate on each batch...
   }
   ```
   
   When I'm trying to execute a program, I'm getting segmentation fault. I used 
valgrind to locate the errors. Valgrind shows very big amount of `Mismatched 
free() / delete / delete []` errors and some errors `Invalid read of size X` 
caused after calling `arrow::RecordBatchReader::Next()`.
   
   Here is full valgrind output.
   
[valgrind_stderr.txt](https://github.com/apache/arrow/files/14182801/valgrind_stderr.txt)
   
   I tried to use precompiled version of libarrow and there were no such 
problems, but for my project it is required to build it for myself. Also I 
tried to read the whole table to memory using `arrow_reader->ReadTable(&table)` 
and it works without segfaults.
   Do you familiar with such kind of errors and how to fix them? 
   
   ### Component(s)
   
   C++, Parquet


-- 
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]

Reply via email to