Describe the bug, including details regarding any error messages, version, and platform.
I've been fuzzing Python C extension modules for a small research project, and this one came up. It reproduces with the binary wheel from a plain pip install pyarrow.
Versions
pyarrow 25.0.0, CPython 3.12.3, Ubuntu 24.04 x86_64.
Reproducer
import pyarrow as pa
pa.output_stream(pa.py_buffer(b'x'))
The process aborts (SIGABRT, exit 134) after printing:
/arrow/cpp/src/arrow/io/memory.cc:165: Check failed: buffer->is_mutable() Must pass mutable buffer
[1] 3911118 IOT instruction (core dumped) python
memoryview(b'') and an empty py_buffer do the same:
pa.output_stream(memoryview(b'')) # SIGABRT
pa.output_stream(pa.py_buffer(b'')) # SIGABRT
What does work
A mutable buffer, a path, and BufferOutputStream are all fine:
>>> b = pa.allocate_buffer(16)
>>> b.is_mutable
True
>>> type(pa.output_stream(b))
<class 'pyarrow.lib.FixedSizeBufferWriter'>
>>> type(pa.output_stream('/tmp/o.bin'))
<class 'pyarrow.lib.OSFile'>
And pa.py_buffer is documented to produce a read-only buffer:
>>> pa.py_buffer(b'x').is_mutable
False
Why I think it is worth reporting
output_stream's own docstring lists buffer among the accepted source types:
source : str, Path, buffer, file-like object
The source to open for writing.
so passing a buffer is the documented usage, and a read-only one terminates the interpreter rather than raising.
This looks to me like a bug, but I'm not certain it is one, so I'm filing an issue.
Component(s)
Python
Describe the bug, including details regarding any error messages, version, and platform.
I've been fuzzing Python C extension modules for a small research project, and this one came up. It reproduces with the binary wheel from a plain
pip install pyarrow.Versions
pyarrow 25.0.0, CPython 3.12.3, Ubuntu 24.04 x86_64.
Reproducer
The process aborts (SIGABRT, exit 134) after printing:
memoryview(b'')and an emptypy_bufferdo the same:What does work
A mutable buffer, a path, and
BufferOutputStreamare all fine:And
pa.py_bufferis documented to produce a read-only buffer:Why I think it is worth reporting
output_stream's own docstring listsbufferamong the accepted source types:so passing a buffer is the documented usage, and a read-only one terminates the interpreter rather than raising.
This looks to me like a bug, but I'm not certain it is one, so I'm filing an issue.
Component(s)
Python