-
Notifications
You must be signed in to change notification settings - Fork 777
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
Python::assume_gil_acquired() can infer static lifetime. #800
Comments
Internally, we have lots of codes like let py = Python::assume_gil_acquired();
let _pool = gil::GILPool::new_no_pointers(py); In such cases, struct GILPool { ... }
let _pool = GILPool::new();
let py = _pool.py(); // the existance of GILPool already assumes GIL is hold |
For now, could I open a PR that adds |
Sure thing, I'd be happy to see the unsoundness fixed sooner rather than later. Don't worry about #797. I'll fix it up when I get a chance; I've been quite busy recently. When I have some time again I was planning to first help with bugfixes for 0.9 before we begin making breaking changes like #797 for an 0.10 release |
Ooops, because of the lifetime problem, it looks like we need the same trick as #797 to use |
Which trick from #797 do you mean? |
I mean the changes of CallbackConverter. |
Ok. I'll try to start figuring #797 again soon. Maybe next week. I think there are still more bugfixes we could do for |
Thank you. We don't have to be so upset, but please let me complete the PR if you were still busy next week.
Since #839 has some breaking changes the next version should be 0.10 if we apply semver explicitly. |
Now that #858 is merged I guess that |
Now that we have |
As per the comment on #797 we should probably remove
Python::assume_gil_acquired()
, because it can give you aPython<'static>
thanks to the lifetime inference. This is almost certainly unsound.I think it probably explains this crash #653
See this playground for a minimal example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=213173005786e15199cf0312079c3d72
A function
assume_gil_acquired()
would still be useful, but I think it needs to return a type without a lifetime, so that there is no risk of incorrect inference. For example, something like this:In the above example, the
Python
lifetime is tied exactly to the lifetime of theAssumeGILAcquired
token, so we can avoid'static
lifetime problems.The text was updated successfully, but these errors were encountered: