Go version

master

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2883029808=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'

What did you do?

plugin.go

package main

func init() {
    panic("unexpected call to init")
}

func main() {}

go build -gcflags=all=-N -l -buildmode=plugin

main.go

package main

import (
    "fmt"
    "plugin"
)

func init() {
    _, err := plugin.Open("issue75102.so")
    if err == nil {
        panic("unexpected success to open a different version plugin")
    }
}

func main() {
    fmt.Println("done")
}

go build

What did you see happen?

panic("unexpected call to init")

What did you expect to see?

print "done"

Comment From: gopherbot

Change https://go.dev/cl/697675 mentions this issue: runtime: skip doInit of plugins in rumtime.main

Comment From: gabyhelp

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: WangLeonard

It was introduced by https://go-review.googlesource.com/c/go/+/520375 , affecting go1.22 and above

Comment From: WangLeonard

Maybe we need a backport? Thanks.

@gopherbot please open backport issues.

Comment From: gopherbot

Backport issue(s) opened: #75146 (for 1.24), #75147 (for 1.25).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

Comment From: gopherbot

Change https://go.dev/cl/699335 mentions this issue: [release-branch.go1.24] runtime: skip doInit of plugins in runtime.main

Comment From: gopherbot

Change https://go.dev/cl/699336 mentions this issue: [release-branch.go1.25] runtime: skip doInit of plugins in runtime.main