1fanwang opened a new pull request, #51246:
URL: https://github.com/apache/arrow/pull/51246

   ### Rationale for this change
   
   `pa.MemoryMappedFile()` can be constructed without opening a file. Calling 
resize on that object dereferences an empty native handle and takes down the 
Python process with a SIGSEGV, so an application cannot catch or recover from 
it.
   
   ### What changes are included in this PR?
   
   The resize path now applies the same open-state check the other file 
operations already use, before it reaches the native resize call. A directly 
constructed object raises `ValueError("I/O operation on closed file")`.
   
   ### Are these changes tested?
   
   Yes. The regression drives the call in a subprocess so a crash is observable 
rather than fatal to the test run.
   
   ```console
   $ git checkout main -- python/pyarrow/io.pxi && python -m pytest \
       python/pyarrow/tests/test_io.py -k memory_map_resize -q
   E  subprocess.CalledProcessError: Command '[...]' died with 
<Signals.SIGSEGV: 11>.
   1 failed, 162 deselected in 0.73s
   
   $ git checkout HEAD -- python/pyarrow/io.pxi && python -m pytest \
       python/pyarrow/tests/test_io.py -k memory_map_resize -q
   2 passed, 161 deselected in 0.23s
   ```
   
   ### Are there any user-facing changes?
   
   Yes. Misuse of a directly constructed memory-mapped file now raises a Python 
exception instead of terminating the process.
   
   **This PR contains a "Critical Fix".** It fixes a process crash reachable 
from ordinary Python-level object state.
   


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