{"action":"created","issue":{"url":"https://api.github.com/repos/pybind/pybind11/issues/526","repository_url":"https://api.github.com/repos/pybind/pybind11","labels_url":"https://api.github.com/repos/pybind/pybind11/issues/526/labels{/name}","comments_url":"https://api.github.com/repos/pybind/pybind11/issues/526/comments","events_url":"https://api.github.com/repos/pybind/pybind11/issues/526/events","html_url":"https://github.com/pybind/pybind11/issues/526","id":191189894,"number":526,"title":"Factory function crashes","user":{"login":"nimamox","id":12006975,"avatar_url":"https://avatars.githubusercontent.com/u/12006975?v=3","gravatar_id":"","url":"https://api.github.com/users/nimamox","html_url":"https://github.com/nimamox","followers_url":"https://api.github.com/users/nimamox/followers","following_url":"https://api.github.com/users/nimamox/following{/other_user}","gists_url":"https://api.github.com/users/nimamox/gists{/gist_id}","starred_url":"https://api.github.com/users/nimamox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nimamox/subscriptions","organizations_url":"https://api.github.com/users/nimamox/orgs","repos_url":"https://api.github.com/users/nimamox/repos","events_url":"https://api.github.com/users/nimamox/events{/privacy}","received_events_url":"https://api.github.com/users/nimamox/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2016-11-23T05:06:39Z","updated_at":"2016-12-04T15:36:33Z","closed_at":"2016-11-23T21:37:13Z","body":"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 function`int 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. \r\n\r\n```\r\nPfmApi* newPfmApi(){\r\n    PfmApi* pfm = 0;\r\n    PfmApiFactory(&pfm);\r\n    return pfm;\r\n}\r\n```\r\n```\r\nm.def(\"newPfmApi\", &newPfmApi);\r\n```\r\nNow 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:\r\n```\r\nm.def(\"newPfmApi\", &newPfmApi, py::return_value_policy::reference);\r\n```\r\nThe complete binding code is at [http://paste.ubuntu.com/23520659/](http://paste.ubuntu.com/23520659/)"},"comment":{"url":"https://api.github.com/repos/pybind/pybind11/issues/comments/264710718","html_url":"https://github.com/pybind/pybind11/issues/526#issuecomment-264710718","issue_url":"https://api.github.com/repos/pybind/pybind11/issues/526","id":264710718,"user":{"login":"jagerman","id":4459524,"avatar_url":"https://avatars.githubusercontent.com/u/4459524?v=3","gravatar_id":"","url":"https://api.github.com/users/jagerman","html_url":"https://github.com/jagerman","followers_url":"https://api.github.com/users/jagerman/followers","following_url":"https://api.github.com/users/jagerman/following{/other_user}","gists_url":"https://api.github.com/users/jagerman/gists{/gist_id}","starred_url":"https://api.github.com/users/jagerman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jagerman/subscriptions","organizations_url":"https://api.github.com/users/jagerman/orgs","repos_url":"https://api.github.com/users/jagerman/repos","events_url":"https://api.github.com/users/jagerman/events{/privacy}","received_events_url":"https://api.github.com/users/jagerman/received_events","type":"User","site_admin":false},"created_at":"2016-12-04T15:36:33Z","updated_at":"2016-12-04T15:36:33Z","body":"Also note that you don't need the `newPfmApiDel` function: the important part is telling pybind to use it as a holder (the second template argument to `py::class_`)."}}
{"actor":{"display_login":"jagerman"}}