Closed amlwwalker closed 1 year ago
EDIT - it seems that passing a plugin around is causing the crash... is that something that makes any sense?
@codefromthecrypt @knqyf263 - I have put a 'broken' example here demonstrating the issue.
Specifically here - I call Content
when I first load the plugin, but when I try to call it from somewhere else using a reference to the plugin the plugin seems to crash with not further information.
I'm not sure how to debug this - I am using Goland - wondering if you have any tips on how to debug a plugin (when its called from the host)
P.S: Is the plugin expecting to only be run once and then it closes? Do I have to either keep loading it every time I want to use it, or do I have to somehow keep the main()
function in the plugin running constantly with a waitgroup of something?
I got it!
The issue was the plugin loader was defer p.Close(ctx)
closing. I had not thought that this needed to be open for a plugin to work, but it makes sense now. I'll add that to my struct and close it later.
Hopefully this helps someone
Thanks for putting the comment back about what happens. It helps to share this info, @amlwwalker, even if only to re-enforce the point.
Hey, I might have missed something. I am loading plugins like so
then from "somewhere else" I am calling
If I were to do this directly, in the first code snippet above where I am adding the plugin to the map, it works fine. However when I try to do this from this function, I get the error
My guess is that I would have to keep calling
.Load
on the plugin however I would have thought all would be OK as I am storing the plugin in the map as a reference, but for some reason that doesnt' work? Any tips as to why?(on another note, is there ways to expose functions in the plugin to the 'host' at runtime - i.e functions that are not known about in the proto file. Perhaps with reflection, or perhaps with a map of functions in the plugin that are exposed in the proto file?)
Thanks for your help!