main.go: package main
import "plugin" func main() { p, err := plugin.Open("../my_plugin/my_plugin.so") if err != nil { panic(err) } v, err := p.Lookup("V") if err != nil { panic(err) } f, err := p.Lookup("F") if err != nil { panic(err) } *v.(*int) = 7 f.(func())() // prints "Hello, number 7" } my_plugin package main import "fmt" var V int func F() { fmt.Printf("Hello, number %d\n", V) } go version go version go1.21.1 darwin/arm64 Running make planic with: fatal error: forcegc: phase error goroutine 5 [running]: runtime.throw({0x129d8dc52?, 0x102a4ef10?}) /usr/local/go/src/runtime/panic.go:1077 +0x40 fp=0x14000046790 sp=0x14000046760 pc=0x129cf29e0 runtime.forcegchelper() /usr/local/go/src/runtime/proc.go:319 +0x114 fp=0x140000467d0 sp=0x14000046790 pc=0x129cf5d64 runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x140000467d0 sp=0x140000467d0 pc=0x129d1f164 created by runtime.init.6 in goroutine 1 /usr/local/go/src/runtime/proc.go:310 +0x24 goroutine 1 [runnable]: os.NewFile(0x1?, {0x129d8c228?, 0xb?}) /usr/local/go/src/os/file_unix.go:105 +0xb8 fp=0x1400011faa0 sp=0x1400011faa0 pc=0x129d7d1c8 os.init() /usr/local/go/src/os/file.go:66 +0x310 fp=0x1400011fad0 sp=0x1400011faa0 pc=0x129d7e970 runtime.doInit1(0x129e8fc20) /usr/local/go/src/runtime/proc.go:6740 +0xd4 fp=0x1400011fc00 sp=0x1400011fad0 pc=0x10298f6f4 runtime.doInit({0x129e8fee0, 0xa, 0x1400001e0f0?}) /usr/local/go/src/runtime/proc.go:6707 +0x38 fp=0x1400011fc20 sp=0x1400011fc00 pc=0x10298f5d8 plugin.open({0x1029b8f84, 0x19}) /usr/local/go/src/plugin/plugin_dlopen.go:95 +0x520 fp=0x1400011fea0 sp=0x1400011fc20 pc=0x1029b4fe0 plugin.Open(...) /usr/local/go/src/plugin/plugin.go:80 main.main() /Users/laplante/go/src/my_main/main.go:6 +0x30 fp=0x1400011ff30 sp=0x1400011fea0 pc=0x1029b5710 runtime.main() /usr/local/go/src/runtime/proc.go:267 +0x2bc fp=0x1400011ffd0 sp=0x1400011ff30 pc=0x102981a8c runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x1400011ffd0 sp=0x1400011ffd0 pc=0x1029a9ac4 goroutine 2 [force gc (idle)]: runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?) /usr/local/go/src/runtime/proc.go:398 +0xc8 fp=0x14000046f90 sp=0x14000046f70 pc=0x102981eb8 runtime.goparkunlock(...) /usr/local/go/src/runtime/proc.go:404 runtime.forcegchelper() /usr/local/go/src/runtime/proc.go:322 +0xb8 fp=0x14000046fd0 sp=0x14000046f90 pc=0x102981d48 runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x14000046fd0 sp=0x14000046fd0 pc=0x1029a9ac4 created by runtime.init.6 in goroutine 1 /usr/local/go/src/runtime/proc.go:310 +0x24 goroutine 3 [GC sweep wait]: runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?) /usr/local/go/src/runtime/proc.go:398 +0xc8 fp=0x14000047760 sp=0x14000047740 pc=0x102981eb8 runtime.goparkunlock(...) /usr/local/go/src/runtime/proc.go:404 runtime.bgsweep(0x0?) /usr/local/go/src/runtime/mgcsweep.go:280 +0xa0 fp=0x140000477b0 sp=0x14000047760 pc=0x10296dad0 runtime.gcenable.func1() /usr/local/go/src/runtime/mgc.go:200 +0x28 fp=0x140000477d0 sp=0x140000477b0 pc=0x102962698 runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x140000477d0 sp=0x140000477d0 pc=0x1029a9ac4 created by runtime.gcenable in goroutine 1 /usr/local/go/src/runtime/mgc.go:200 +0x6c goroutine 4 [GC scavenge wait]: runtime.gopark(0x14000070000?, 0x1029d1eb0?, 0x1?, 0x0?, 0x140000031e0?) /usr/local/go/src/runtime/proc.go:398 +0xc8 fp=0x14000047f50 sp=0x14000047f30 pc=0x102981eb8 runtime.goparkunlock(...) /usr/local/go/src/runtime/proc.go:404 runtime.(*scavengerState).park(0x102a503c0) /usr/local/go/src/runtime/mgcscavenge.go:425 +0x5c fp=0x14000047f80 sp=0x14000047f50 pc=0x10296b1dc runtime.bgscavenge(0x0?) /usr/local/go/src/runtime/mgcscavenge.go:653 +0x44 fp=0x14000047fb0 sp=0x14000047f80 pc=0x10296b754 runtime.gcenable.func2() /usr/local/go/src/runtime/mgc.go:201 +0x28 fp=0x14000047fd0 sp=0x14000047fb0 pc=0x102962638 runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x14000047fd0 sp=0x14000047fd0 pc=0x1029a9ac4 created by runtime.gcenable in goroutine 1 /usr/local/go/src/runtime/mgc.go:201 +0xac goroutine 6 [runnable]: runtime.runfinq() /usr/local/go/src/runtime/mfinal.go:176 fp=0x140000487d0 sp=0x140000487d0 pc=0x129cd4db0 runtime.goexit() /usr/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x140000487d0 sp=0x140000487d0 pc=0x129d1f164 created by runtime.createfing in goroutine 1 /usr/local/go/src/runtime/mfinal.go:163 +0x84 -- 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/c5e8faf6-d65b-44f0-9ba9-a3b54786ed44n%40googlegroups.com.