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

Calling Python function many times causes SEGV or hang. #280

Closed
pandaman64 opened this issue Nov 18, 2018 · 4 comments
Closed

Calling Python function many times causes SEGV or hang. #280

pandaman64 opened this issue Nov 18, 2018 · 4 comments

Comments

@pandaman64
Copy link

🐛 Bug Reports

Repeatedly calling a Python function eventually fails at the 256'th call.
The process terminates with SEGV or sometimes hang indefinitely.

🌍 Environment

  • Your operating system and version:
    Ubuntu 18.04.1 LTS on Windows Subsystem for Linux.
    I also noticed this bug on NixOS.

  • Your python version:
    Python 3.6.6

  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?:
    Installed via apt

  • Your rust version (rustc --version):
    rustc 1.32.0-nightly (6b9b97bd9 2018-11-15)

  • Are you using the latest pyo3 version? Have you tried using latest master (replace version = "0.x.y" with git = "https://github.com/PyO3/pyo3")?
    0.5
    I confirmed the latest master still reproduces the bug.

💥 Reproducing

extern crate pyo3;

use pyo3::prelude::*;

#[test]
fn call_many_times() -> PyResult<()> {
    let guard = Python::acquire_gil();
    let py = guard.python();
    let math = py.import("math")?;
    let exp = math.get("exp")?;

    for i in 0..100000 {
        println!("{}", i);
        exp.call1((1.0_f64, ))?;
    }

    Ok(())
}

and cargo test -- --nocapture (I added --nocapture to find the limit).
You can get the code here: https://github.com/pandaman64/pyo3-test

Thank you

@kngwyu
Copy link
Member

kngwyu commented Nov 18, 2018

Maybe related to #271?

@kngwyu
Copy link
Member

kngwyu commented Nov 18, 2018

@pandaman64
Could you please test with #281?
It's a really serious and silly bug. Sorry 😓

@pandaman64
Copy link
Author

@kngwyu It's working! Thanks!

@konstin
Copy link
Member

konstin commented Nov 24, 2018

Fixed by 0.5.1 then

@konstin konstin closed this as completed Nov 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants