I have a question about a Swift runtime crash I am seeing. It may be a bona fide problem with the Swift runtime, but it just as well might be an error in my code. I don't know where else to ask for help, and I don't think this issue is quite appropriate for the bug reporter.
I have come up with what looks like a workable method for loading in-process plugins in Swift. It involves annotating a method with the (currently technically private)
@_cdecl attribute, in order to provide a function I can load and call using dlopen/dlsym. You can view the full code on my GitHub repo here. On my machine, it loads the plugin, calls the exported method, and marshals the object back using
Unmanaged<T> and a pointer. However, when I try to call a method on the marshaled object, I get a segmentation fault within the
swift_unknownObjectRetain method. I do not know enough about the Swift runtime internals to pin this down to a specific source line, as all I can see in the Xcode debugger is a disassembly.
If someone could please lend me a hand and help me figure out what's going wrong, I would be very appreciative. Thanks!