Skip to content

Factory function crashes #526

Closed
Closed
@nimamox

Description

@nimamox

I'm new in using pybind11, so I apologize if my problem is stupid. I had previously written a Python binding for this library called Pismo File Mount, that seems to be broken since I've updated Python and pybind11. The library has a functionint PfmApiFactory (PfmApi** api) which retrieves an instance of the PfmApi interface. I've written a wrapper function to call newPfmApi and return it back to Python.

PfmApi* newPfmApi(){
    PfmApi* pfm = 0;
    PfmApiFactory(&pfm);
    return pfm;
}
m.def("newPfmApi", &newPfmApi);

Now this worked fine, and the previously-built library still works. But now after I compile the code, when I call newPfmApi, I get segfault. I inspected newPfmApi and PfmApiFactory is actually running without error and the instance is created, but upon returning pfm, it causes a segfault. I've also tested other return value policies, but to no avail:

m.def("newPfmApi", &newPfmApi, py::return_value_policy::reference);

The complete binding code is at http://paste.ubuntu.com/23520659/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions