clipper icon indicating copy to clipboard operation
clipper copied to clipboard

PyBind Segmentation Fault

Open holmesco opened this issue 9 months ago • 2 comments

Hi,

I am hoping to use your repo in part of my research. I installed it according to the instructions on the README. The C++ tests are passing, but when I tried to run the Python example, I got a seg fault. I can reproduce the issue by calling to the Euclidean Distance invariant function as shown below:

import numpy as np
import clipperpy

if __name__ == "__main__":
    iparams = clipperpy.invariants.EuclideanDistanceParams()
    iparams.sigma = 0.01
    iparams.epsilon = 0.02
    invariant = clipperpy.invariants.EuclideanDistance(iparams)
    
    d1 = np.array([[1.0,2.0,3.0]]).T.astype(np.float64)
    d2 = np.array([[1.0,2.0,3.0]]).T.astype(np.float64)
    d3 = np.array([[1.0,2.0,3.0]]).T.astype(np.float64)
    d4 = np.array([[1.0,2.0,3.0]]).T.astype(np.float64)
        
    scr = invariant(d1, d2, d3, d4)

The seg fault occurs when "invariant" is called.

I am running everything in a container, but I don't think that this should be causing the problem. Could you let me know the versions that you are using to get a working version of the python code (e.g., pybind11, python, cmake, etc.)?

holmesco avatar Mar 21 '25 22:03 holmesco

hi Connor, i just tried to install and run your script on Ubuntu 24.04, Python 3.11 and i also got a segfault.

I created a pixi virtualenv with py3.8 and everything worked as expected. So something between py3.8 and py3.11 has made pybind unhappy. I also tried updating pybind11 to its latest 2.13.6 - it also segfaulted on py3.11 though.

I might be able to look at this later, or if you solve it, I'd welcome a PR!

plusk01 avatar Mar 21 '25 22:03 plusk01

Thanks for the quick response!

Indeed, py3.8 does work. That's enough for me to go on for now, but I will PR if I end up updating the binding.

holmesco avatar Mar 21 '25 23:03 holmesco