Segfault from pyo3 trying to call PyBuffer::drop
after Python interpreter already finalized
#4632
Labels
PyBuffer::drop
after Python interpreter already finalized
#4632
Bug Description
I got a segfault in my Python library from pyo3 trying to call
PyBuffer::drop
after the Python interpreter was already finalized. (See kylebarron/arro3#230).Trying to acquire the GIL made this
assert_ne!
panic.The similar C++-based Python library
pyarrow
performs a check for whether the interpreter is initialized before trying to drop the value.I already worked around this in kylebarron/arro3#231 by checking if the interpreter is initialized before calling
drop
.But perhaps this is something that should be fixed upstream in pyo3.
Steps to Reproduce
Then run
Then exit the Python interpreter, e.g. with control+D. You should see a segfault backtrace. This appears to be consistently reproducible for me.
Backtrace
Your operating system and version
MacOS Sonoma 14.6.1
Your Python version (
python --version
)3.11.8
Your Rust version (
rustc --version
)1.82.0
Your PyO3 version
0.22
How did you install python? Did you use a virtualenv?
Installed Python via pyenv. Virtualenv provided by uv.
Additional Info
No response
The text was updated successfully, but these errors were encountered: