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

Auto-implementation of ToPyObject allows PyObject to outlive object #308

Closed
athre0z opened this issue Dec 11, 2018 · 1 comment
Closed

Comments

@athre0z
Copy link
Contributor

athre0z commented Dec 11, 2018

🌍 Environment

  • Your operating system and version: macOS 14.2
  • Your python version: Python 3.6
  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?: macports, yes
  • Your rust version (rustc --version): rustc 1.32.0-nightly (14997d56a 2018-12-05)
  • Are you using the latest pyo3 version? -- Yes, I'm tested this on master

💥 Reproducing

I PRed two tests that reliably reproduce the issue in #307.

@athre0z
Copy link
Contributor Author

athre0z commented Dec 11, 2018

It doesn't appear to be specific to IntoPyTuple, it also crashes when constructing the tuple from an iterator (I added two more tests to the PR).

Edit: Alright, turns out that I just did the object allocation wrong. For code that still causes a crash, please check this commit. Nevertheless, it should not be possible to cause a SIGSEGV without invoking unsafe code. I suspect the issue essentially runs down to any pyclass auto-implementing ToPyObject with code that transforms a non-mut reference into a PyObject, allowing the resulting object to live longer than the original reference.

@athre0z athre0z changed the title SIGSEGV when using objects created using IntoPyTuple Auto-implementation of ToPyObject allow for PyObject outliving object Dec 11, 2018
@athre0z athre0z changed the title Auto-implementation of ToPyObject allow for PyObject outliving object Auto-implementation of ToPyObject allows PyObject to outlive object Dec 11, 2018
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