`Python::allow_threads` is unsound in the presence of `send_wrapper`.
Open
@mejrs is already working on this.
Since Feb 10, 2022.
1.0-candidate
hard
Unsound
- Dominant language
- Rust
- Stars
- 16.2k
- Forks
- 1k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 66
Description
It allows smuggling Python types into the closure:
use pyo3::prelude::*;
use pyo3::types::PyString;
use send_wrapper::SendWrapper;
fn main() {
Python::with_gil(|py| {
let string = PyString::new(py, "foo");
let wrapped = SendWrapper::new(string);
py.allow_threads(|| {
let smuggled: &PyString = *wrapped;
println!("{:?}", smuggled);
});
});
}
Results in
error: process didn't exit successfully: target\debug\my_module.exe (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
So I'm not sure whose fault it is:
- Ours, for using
Sendfor something it wasn't meant to. send_wrapper's, for assuming others didn't put arbitrary restrictions onSend.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.