Skip to content

ENH,BIND: Return more PointClouds #35

Description

@RuhiRG

In dSEAMS raw pointers have been used, but in pybind11 when I bind a function with raw pointers. It gives segmentation error. Here is the git commit I made. The error it shows when I try to use ipython is as follows:

In [1]: cyoda.clearPointCloud(mpt)
Out[1]: <bbdir.cyoda.PointCloudDouble at 0x7f72d1e91130>

In [2]: mpt = cyoda.clearPointCloud(mpt)

In [3]: mpt
Out[3]: <bbdir.cyoda.PointCloudDouble at 0x7f72d1c333f0>

In [4]: cyoda.readXYZ("conftest.xyz", mpt)
Stack trace (most recent call last):
#31   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e8aa08d, in _PyRun_SimpleFileObject
#30   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e8aa70f, in 
#29   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e895772, in 
#28   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e899369, in 
#27   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e87a9de, in PyEval_EvalCode
#26   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e87b325, in 
#25   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7c73ce, in _PyEval_EvalFrameDefault
#24   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7efc70, in PyObject_Call
#23   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e806802, in 
#22   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e806a73, in 
#21   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7c385c, in _PyEval_EvalFrameDefault
#20   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7d04cb, in PyObject_Vectorcall
#19   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7ee728, in 
#18   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e88f996, in 
#17   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e88edb8, in 
#16   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7c6478, in _PyEval_EvalFrameDefault
#15   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e88edb8, in 
#14   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7c6478, in _PyEval_EvalFrameDefault
#13   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e88edb8, in 
#12   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7c385c, in _PyEval_EvalFrameDefault
#11   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7d04cb, in PyObject_Vectorcall
#10   Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7d05de, in 
#9    Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e89208d, in 
#8    Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e87a9de, in PyEval_EvalCode
#7    Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e87b325, in 
#6    Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7c385c, in _PyEval_EvalFrameDefault
#5    Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7b6e12, in _PyObject_MakeTpCall
#4    Object "/users/home/ruhila/micromamba/envs/dseams/bin/python3.11", at 0x56400e7d6d45, in 
#3    Object "/users/home/ruhila/Git/Github/dSEAMS/pyseams/bbdir/cyoda.cpython-311-x86_64-linux-gnu.so", at 0x7f72d1be08a7, in 
#2    Object "/users/home/ruhila/Git/Github/dSEAMS/pyseams/bbdir/cyoda.cpython-311-x86_64-linux-gnu.so", at 0x7f72d1be94a3, in 
#1    Object "/users/home/ruhila/micromamba/envs/dseams/lib/libyodaLib.so", at 0x7f72d1aef46c, in sinp::readXYZ(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, molSys::PointCloud<molSys::Point<double>, double>*)
#0    Object "/lib64/libc.so.6", at 0x7f72e1700e0b, in 
Segmentation fault (Address not mapped to object [0x30])
Segmentation fault (core dumped)

The C++ function code takes the input and process the object in place, returning an integer status code. The pybind11 documentation notes that there are issues with changes to native containers. The simplest solution would be to change the seams-core function to take a single input string (filename) and return a populated PointCloud object instead of an int.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgsoc23For GSoC23 and related outputspython-bindingsFor discussions of the python bindings

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions