-
Notifications
You must be signed in to change notification settings - Fork 783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easy dangling PyObject with GILPool #864
Comments
FWIW after #869 then we will need one line of |
I'm sorry but I can't understand why this problem is related to struct PyAny<'a>(...);
impl PyAny {
fn from_borrowed(ptr: ...) -> Self {
Py_INCREF(ptr);
Self(ptr)
}
fn from_owned(ptr: ...) -> Self {
Self(ptr)
}
}
impl<'a> Drop for PyAny<'a> {
fn drop(&mut self) {
Py_DECREF(self.0)
}
} So its reference count is not affected by |
@kngwyu I agree with what what you say and how you propose |
Ah, sorry, I just misread. |
FWIW; the change to
|
This sample code produces a dangling
PyObject
after theGILPool
is dropped:As seen by the output:
I think what must be going on is that
obj
has a lifetime tied topy
, but it is actually only valid for the lifetime ofpool
. Because of the wrong lifetime semantics the Rust compiler lets us create the dangling pointer.I'm not sure yet exactly what the solution should be. Maybe the change to
GILPool / py
relationship proposed in #800 will mitigate this issue.I wonder whether this issue combined with #756 is telling us that the right design is really
PyAny<'a>
as proposed in #679The text was updated successfully, but these errors were encountered: