Skip to content
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

Release pool unsoundness #756

Closed
Alexander-N opened this issue Feb 3, 2020 · 1 comment
Closed

Release pool unsoundness #756

Alexander-N opened this issue Feb 3, 2020 · 1 comment

Comments

@Alexander-N
Copy link
Member

Alexander-N commented Feb 3, 2020

Follow up for #720 where NameErrors and SIGSEGVs were found. The error can be observed with two tests running in parallel (might need a few tries):

#[test]
fn test_release_race1() {
    let gil = Python::acquire_gil();
    let py = gil.python();
    println!("make ob1");
    let ob1 = py.eval("object()", None, None).unwrap();
    py.import("datetime").unwrap();
    py_run!(py, ob1, "print('ob1' + str(ob1))");
}

#[test]
fn test_release_race2() {
    let gil = Python::acquire_gil();
    let py = gil.python();
    println!("make ob2");
    let ob2 = py.eval("object()", None, None).unwrap();
    py.import("datetime").unwrap();
    py_run!(py, ob2, "print('ob2' + str(ob2))");
}

What might be happening is:

  • ob1 gets put into the release pool
  • the import releases the GIL temporarily
  • test_release_race2 makes progress and ob2 gets put into the release pool
  • test_release_race1 finishes and with dropping of it's GILGuard ob2 instead of ob1 is popped from the relase pool
  • test_release_race2 fails because ob2 has been freed
@davidhewitt
Copy link
Member

Now that #887 is merged we should have resolved the thread safety issues here 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants