marinelay opened a new issue, #50831:
URL: https://github.com/apache/arrow/issues/50831
### 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
```python
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:
```python
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:
```python
>>> 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:
```python
>>> 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
--
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]