pyo3: 'extract' sometimes causes segfault on pypy

πŸ› Bug Reports

pypy3 often raise Segmentation fault (core dumped) and sometimes work well.
I checked work well by python3.6 .

🌍 Environment

  • Your operating system and version: Ubuntu 16.04.6 LTS
  • Your python version: pypy3.6-v7.1.1
  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?: build from source
  • Your rust version (rustc --version): rustc 1.36.0-nightly (a3404557c 2019-05-03)
  • 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")? pyo3 = { version = β€œ0.7.0”, features = [β€œextension-module”] }

πŸ’₯ Reproducing

use pyo3::prelude::*;
use pyo3::types::PyList;

#[pyfunction]
fn seg_fault_example(_py: Python<'_>, lists: &PyList) -> PyResult<usize> {
    let lists: Vec<Vec<u8>> = lists.extract()?;
    Ok(lists.len())
}

#[pymodule]
pub fn my_module(_py: Python, m: &PyModule) -> PyResult<()> {
    m.add_wrapped(wrap_pyfunction!(seg_fault_example))?;
    Ok(())
}
module@account:~/$ pypy3-c 
Python 3.6.1 (784b254d669919c872a505b807db8462b6140973, Aug 28 2019, 14:11:37)
[PyPy 7.1.1-beta0 with GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``pypy HIT generator''

>>>> import my_module
>>>> my_module.seg_fault_example([b'41241', b'2364574', b'3342241'])
3
>>>> my_module.seg_fault_example([b'41241', b'2364574', b'334224'])
3
>>>> my_module.seg_fault_example([b'41241', b'2364574', b'33422'])
Segmentation fault (core dumped)

It looks List extracting cause, but not only List but other types are also suspicious.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Sorry, I’ll try it this weekend