xtensor-stack / xtensor-python

Python bindings for xtensor
BSD 3-Clause "New" or "Revised" License
347 stars 58 forks source link

Segfault on failed dispatching of an overrided method involving a pyarray argument #174

Closed PerretB closed 5 years ago

PerretB commented 5 years ago

I am not sure if the bug comes from xtensor-python or pybind11 but as far as I can tell it is specific to xtensor-python.

Assume that we have the following cpp code:

m.def("foo", [](xt::pyarray<float> array){return 0;});

with m a pybind11 module.

Then, the following python instruction leads to a segfault:

foo("bar")

Note that this does not happen when using pybind11 wrapper for numpy arrays. Trying to call the following definition:

m.def("foo", [](pybind11::array_t<float> array){return 0;});

with a string argument produces the expected error:

TypeError: foo(): incompatible function arguments. The following argument types are supported:
    1. (arg0: numpy.ndarray[float32]) -> int

Also note that I remember that this was working fine a few months ago (before summer).