Segfault when using bindgen to consume a C++ API

I'm writing a compositor with Mir (links below) which only exposes a C++ API. Using bindgen this has mostly been a remarkably painless process but I have one case which always segfaults.

I don't understand C++ super well so my terminology may be of, but lets go:
When I take ownership of instances of certain classes, the application immediately segfaults unless I have marked these classes to only be included as opaque types, then the application segfaults whenever I try to pass it back too C++ in some way (method calls, as function args etc.).

One of these classes is miral::Window
cpp file: mir/window.cpp at main · MirServer/mir · GitHub
h file: mir/window.h at main · MirServer/mir · GitHub

example of problematic method:

I can however use methods that return pointers/references to these class instances and on them use methods or pass them around. Example of one such method:

So far I have worked around it by implementing c functions that call these methods, stores the instance and returns a pointer to the instance. It works but if it is possible to fix the problem without that, it would be great.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.