jorisvandenbossche opened a new issue, #34906:
URL: https://github.com/apache/arrow/issues/34906
### Describe the bug, including details regarding any error messages,
version, and platform.
The following snippet reproduces the issue:
```python
import pyarrow as pa
from pyarrow.cffi import ffi
# Prepare input
schema = pa.schema([('col', pa.int64())])
batches = [
pa.record_batch([[1, 2, 3]], schema),
pa.record_batch([[None, 5, 6]], schema),
]
reader = pa.RecordBatchReader.from_batches(schema, batches)
# create RecordBatchReader
c_stream = ffi.new("struct ArrowArrayStream*")
ptr_stream = int(ffi.cast("uintptr_t", c_stream))
reader._export_to_c(ptr_stream)
# Delete and recreate C++ object from exported pointer
del reader, batches
reader_new = pa.RecordBatchReader._import_from_c(ptr_stream)
reader_new.close()
reader_new.read_all()
```
Backtrace:
```
Thread 1 "python" received signal SIGSEGV, Segmentation fault.
#0 0xffffffffffffffff in ?? ()
#1 0x00007ffff4924a27 in arrow::(anonymous
namespace)::ExportedArrayStream::GetNext (this=0x7fffffffb8f8,
out_array=0x7fffffffb970) at
/home/joris/scipy/repos/arrow/cpp/src/arrow/c/bridge.cc:1675
#2 0x00007ffff4924e2b in arrow::(anonymous
namespace)::ExportedArrayStream::StaticGetNext (stream=0x5555563e9f88,
out_array=0x7fffffffb970) at
/home/joris/scipy/repos/arrow/cpp/src/arrow/c/bridge.cc:1711
#3 0x00007ffff4925466 in arrow::(anonymous
namespace)::ArrayStreamBatchReader::ReadNext (this=0x5555563e9f80,
batch=0x7fffffffba20) at
/home/joris/scipy/repos/arrow/cpp/src/arrow/c/bridge.cc:1787
#4 0x00007ffff47b07cf in arrow::RecordBatchReader::ToRecordBatches
(this=0x5555563e9f80) at
/home/joris/scipy/repos/arrow/cpp/src/arrow/record_batch.cc:340
#5 0x00007ffff47b0a55 in arrow::RecordBatchReader::ToTable
(this=0x5555563e9f80) at
/home/joris/scipy/repos/arrow/cpp/src/arrow/record_batch.cc:354
#6 0x00007ffff710221c in
__pyx_pf_7pyarrow_3lib_17RecordBatchReader_10read_all
(__pyx_v_self=0x7fffd89d2460) at
/home/joris/scipy/repos/arrow/python/build/temp.linux-x86_64-cpython-310/lib.cpp:180605
```
So either on the C++ side, the `ArrayStreamBatchReader::ReadNext` should
check if the stream was closed or not, or on the Python side we could not try
to read if it was closed (although I assume you would run into this when using
it from C++ as well, so it should be fixed at that level).
### Component(s)
C++, Python
--
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]