You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently encountering an issue with my C++ code where I'm interfacing with Python using pybind11. I've defined a custom class FlattenGenerator which uses py::iterator objects to manage Python objects. My problem arises when testing the program with large data sizes like range(10000) while range(10) works fine. I'm encountering a segmentation fault and upon investigation, I've found that the FlattenGenerator object is being destroyed prematurely, causing the segmentation error later.
The peculiar part is that my destructor seems to be called twice. I've attempted to use py::keep_alive to manage the object lifetimes, and have also tried using a custom copy constructor, but none of these have resolved the issue. I'm confused about what could be causing this and how to solve it.
I was wondering if anyone here has had a similar experience or could provide any guidance on what could be going wrong?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I'm currently encountering an issue with my C++ code where I'm interfacing with Python using pybind11. I've defined a custom class
FlattenGenerator
which usespy::iterator
objects to manage Python objects. My problem arises when testing the program with large data sizes likerange(10000)
whilerange(10)
works fine. I'm encountering a segmentation fault and upon investigation, I've found that theFlattenGenerator
object is being destroyed prematurely, causing the segmentation error later.The peculiar part is that my destructor seems to be called twice. I've attempted to use
py::keep_alive
to manage the object lifetimes, and have also tried using a custom copy constructor, but none of these have resolved the issue. I'm confused about what could be causing this and how to solve it.I was wondering if anyone here has had a similar experience or could provide any guidance on what could be going wrong?
Here is a simplified version of my code:
Any help would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions