gdstk icon indicating copy to clipboard operation
gdstk copied to clipboard

Memory issues with RaithData

Open MatthewMckee4 opened this issue 1 year ago • 0 comments

Whenever i try to set FlexPath.raith_data:

import gdstk

raith_data = gdstk.RaithData("base_cell_name", 0, 0, 0, 0, 0, 0, 0)

path = gdstk.FlexPath([(0, 0), (0, 1000)], 5)

path.raith_data = raith_data

I get the following error:

Segmentation fault (core dumped)

Apologies for not having too much info on this error as it only occurs on this specific case.

I believe the issue could be from this function, but it could also be due to the memory assigned to the FlexPath/RaithData objects. I have begun to edit the code on this fork

Some initial changes include making RaithData optional in the Flexpath class

static PyObject* flexpath_object_get_raith_data(FlexPathObject* self, void*) {
    if (!self->flexpath->raith_data.has_value()) {
        Py_RETURN_NONE;
    }

    RaithDataObject* obj = PyObject_New(RaithDataObject, &raithdata_object_type);
    obj = (RaithDataObject*)PyObject_Init((PyObject*)obj, &raithdata_object_type);
    obj->raith_data.copy_from(self->flexpath->raith_data.value());
    return (PyObject*)obj;
}

I'm on Ubuntu 24.04

MatthewMckee4 avatar Aug 22 '24 11:08 MatthewMckee4