aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/cgo/internal/testplugin/plugin_test.go
diff options
context:
space:
mode:
authorWang Deyu <wangdeyu.2021@bytedance.com>2025-08-20 21:33:42 +0800
committerGopher Robot <gobot@golang.org>2025-08-25 10:54:23 -0700
commitea55ca360005c607fa54304d95c6821a6ce20e7c (patch)
tree637e8e82a00f317d3577548ccc4a111711b3d4f5 /src/cmd/cgo/internal/testplugin/plugin_test.go
parent9ae2f1fb574e879402bc5bbac1d2b5d84acce6cb (diff)
downloadgo-ea55ca360005c607fa54304d95c6821a6ce20e7c.tar.xz
runtime: skip doInit of plugins in runtime.main
Plugins may be loaded in the user's init code. If loading fails, md.bad is true, and doInit should not be executed. If loading succeeds, the plugin must run modulesinit and typelinksinit before doInit. Here is not protected by pluginsMu, and in concurrent scenarios it is possible to obtain the moduledata of the plugin that is still in the loading process. Any added modules after loop starts will do their own doInit calls. This fixes the issue introduced by CL 520375. Fixes #75102 Change-Id: I48e91ae21615a0c54176875a6a2dea8e1dade906 Reviewed-on: https://go-review.googlesource.com/c/go/+/697675 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd/cgo/internal/testplugin/plugin_test.go')
-rw-r--r--src/cmd/cgo/internal/testplugin/plugin_test.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cmd/cgo/internal/testplugin/plugin_test.go b/src/cmd/cgo/internal/testplugin/plugin_test.go
index d2d998e5f4..5bff81092c 100644
--- a/src/cmd/cgo/internal/testplugin/plugin_test.go
+++ b/src/cmd/cgo/internal/testplugin/plugin_test.go
@@ -422,3 +422,11 @@ func TestIssue67976(t *testing.T) {
globalSkip(t)
goCmd(t, "build", "-buildmode=plugin", "-o", "issue67976.so", "./issue67976/plugin.go")
}
+
+func TestIssue75102(t *testing.T) {
+ globalSkip(t)
+ // add gcflags different from the executable file to trigger plugin open failed.
+ goCmd(t, "build", "-gcflags=all=-N -l", "-buildmode=plugin", "-o", "issue75102.so", "./issue75102/plugin.go")
+ goCmd(t, "build", "-o", "issue75102.exe", "./issue75102/main.go")
+ run(t, "./issue75102.exe")
+}