Ian,

I did some more digging on the web and landed on this Go issue where you 
had a 
comment: https://github.com/golang/go/issues/18123#issuecomment-264590075. 

The original issue is related c-archive buildmode, but reading further on 
that thread, I am guessing that even for Go shared libraries built with 
c-shared buildmode, invoking a plugin doesn't work due to multiple Go 
runtimes being loaded.

This 
comment: https://github.com/golang/go/issues/18123#issuecomment-469111906 
has a demo that resembles my situation.

Given all this, I am thinking that native C shared library -> Go shared 
library -> Go plugin is an unsupported situation. Am I missing something? 

Thanks,
Karthik.

On Tuesday, January 7, 2020 at 6:20:50 AM UTC-8, Ian Lance Taylor wrote:
>
> On Mon, Jan 6, 2020 at 11:54 PM Karthik Krishnamurthy 
> <karth...@gmail.com <javascript:>> wrote: 
> > 
> > This is probably an unusual situation, but I am working on a product 
> that has the following chain of invocation. 
> > 
> > C (native shared library libfoo.so) -> Go (c-shared libbar.so) 
> > 
> > So basically, a native C shared library invokes a -buildmode=c-shared 
> type Go shared library. This interaction works just fine. 
> > 
> > However, we are augmenting libbar.so (Go shared library) to invoke a 
> Go-style plugin (libplugin.so) using Go's plugin package. The very first 
> attempt of this, failed like this: 
> > 
> > fatal error: runtime: no plugin module data 
> > 
> > 
> > goroutine 17 [running, locked to thread]: 
> > runtime.throw(0xf72b5cc4, 0x1e) 
> >     /usr/local/go/src/runtime/panic.go:774 +0x70 fp=0xc64d1b48 
> sp=0xc64d1b34 pc=0xf71bfdd0 
> > plugin.lastmoduleinit(0xc648e5e0, 0x1001, 0x1001, 0xc64823e8, 0x95b9588) 
> >     /usr/local/go/src/runtime/plugin.go:20 +0xa50 fp=0xc64d1bd4 
> sp=0xc64d1b48 pc=0xf71c1420 
> > plugin.open(0xc64a60c0, 0x26, 0x29, 0xc64a6060, 0x2a) 
> >     /usr/local/go/src/plugin/plugin_dlopen.go:77 +0x388 fp=0xc64d1d2c 
> sp=0xc64d1bd4 pc=0xf7275ad8 
> > plugin.Open(...) 
> >     /usr/local/go/src/plugin/plugin.go:32 
> > zero/base/interfaces.glob..func1(0xc64a60c0, 0x29, 0xf72b2610, 0x11, 
> 0x29, 0x0, 0xf719e2e5, 0xf71d958c) 
> >     /app/base/interfaces/plugin.go:12 +0x2e fp=0xc64d1d68 sp=0xc64d1d2c 
> pc=0xf7276cbe 
> > zero/base.glob..func4(0xf7759c60, 0x21, 0xf7357f80, 0xc64823e0, 
> 0xc64a8445, 0x5, 0xf, 0xe, 0xd, 0xd) 
> >     /app/base/zl_helper.go:28 +0xb4 fp=0xc64d1d9c sp=0xc64d1d68 
> pc=0xf72ac554 
> > main.glob..func10(0xffa1e800, 0x2, 0x2, 0xf7759c60, 0x21, 0xf775ac60, 
> 0x1b, 0x15, 0xc648e5c0, 0x5, ...) 
> >     /app/dec/dec.go:328 +0x7a fp=0xc64d1dd8 sp=0xc64d1d9c pc=0xf72aeb0a 
> > main.glob..func11(0xffa1e800, 0x2, 0x2, 0xf7759c60, 0x21, 0xf775ac60, 
> 0x1b, 0x15, 0xc6496040, 0x5, ...) 
> >     /app/dec/dec.go:368 +0xa3 fp=0xc64d1e34 sp=0xc64d1dd8 pc=0xf72aee13 
> > main.Decorate(0xffa1e800, 0x2, 0x2, 0xf7759c60, 0x21, 0xf775ac60, 0x1b, 
> 0x15, 0xc6436000) 
> >     /app/dec/dec.go:98 +0x1f3 fp=0xc64d1eac sp=0xc64d1e34 pc=0xf72ad0b3 
> > main._cgoexpwrap_079f3b2ec7da_Decorate(0xffa1e800, 0x2, 0x2, 0xf7759c60, 
> 0x21, 0xf775ac60, 0x1b, 0x15, 0x0) 
> >     _cgo_gotypes.go:79 +0x95 fp=0xc64d1ef4 sp=0xc64d1eac pc=0xf72ace15 
> > runtime.call64(0x0, 0xffa1e72c, 0xffa1e79c, 0x24, 0x0) 
> >     /usr/local/go/src/runtime/asm_386.s:571 +0x31 fp=0xc64d1f38 
> sp=0xc64d1ef4 pc=0xf71e9ad1 
> > runtime.cgocallbackg1(0x0) 
> >     /usr/local/go/src/runtime/cgocall.go:314 +0x162 fp=0xc64d1fb0 
> sp=0xc64d1f38 pc=0xf71966f2 
> > runtime.cgocallbackg(0x0) 
> >     /usr/local/go/src/runtime/cgocall.go:191 +0x9d fp=0xc64d1fe0 
> sp=0xc64d1fb0 pc=0xf719650d 
> > runtime.cgocallback_gofunc(0x0, 0x0, 0x0, 0x0) 
> >     /usr/local/go/src/runtime/asm_386.s:810 +0x79 fp=0xc64d1ff0 
> sp=0xc64d1fe0 pc=0xf71eab79 
> > runtime.goexit() 
> >     /usr/local/go/src/runtime/asm_386.s:1325 +0x1 fp=0xc64d1ff4 
> sp=0xc64d1ff0 pc=0xf71eb081 
> > Aborted 
> > 
> > 
> > What is the error indicative of? 
> > 
> > Is invoking go plugin from go shared library supported? 
> > 
> > I know Go plugins have a few restrictions. I have verified that all the 
> above libraries are built on the same machine with the same gcc/go toolkit. 
>
> I wouldn't be surprised if you are the first person to try this.  I'm 
> not surprised that it doesn't work.  I can't think of any fundamental 
> reason why it wouldn't work, so it may be relatively easy to fix if 
> you want to dig into the linker.  I'm not sure. 
>
> Ian 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/82032f0b-5458-42a3-be21-81c00fd253a8%40googlegroups.com.

Reply via email to