Skip to content

Commit ca16999

Browse files
Merge branch 'golang:master' into master
2 parents c4ae081 + bfd130d commit ca16999

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1413
-2167
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The HTTP client returned by [Server.Client] will now redirect requests for
2+
`example.com` and any subdomains to the server being tested.

src/cmd/cgo/internal/testplugin/plugin_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,3 +422,11 @@ func TestIssue67976(t *testing.T) {
422422
globalSkip(t)
423423
goCmd(t, "build", "-buildmode=plugin", "-o", "issue67976.so", "./issue67976/plugin.go")
424424
}
425+
426+
func TestIssue75102(t *testing.T) {
427+
globalSkip(t)
428+
// add gcflags different from the executable file to trigger plugin open failed.
429+
goCmd(t, "build", "-gcflags=all=-N -l", "-buildmode=plugin", "-o", "issue75102.so", "./issue75102/plugin.go")
430+
goCmd(t, "build", "-o", "issue75102.exe", "./issue75102/main.go")
431+
run(t, "./issue75102.exe")
432+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2025 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"fmt"
9+
"plugin"
10+
)
11+
12+
func init() {
13+
_, err := plugin.Open("issue75102.so")
14+
if err == nil {
15+
panic("unexpected success to open a different version plugin")
16+
}
17+
}
18+
19+
func main() {
20+
fmt.Println("done")
21+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2025 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
func init() {
8+
panic("unexpected call to init")
9+
}
10+
11+
func main() {}

src/cmd/compile/internal/ir/mknode.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ func processType(t *ast.TypeSpec) {
258258
var doChildrenWithHiddenBody strings.Builder
259259
var editChildrenBody strings.Builder
260260
var editChildrenWithHiddenBody strings.Builder
261+
var hasHidden bool
261262
for _, f := range fields {
262263
names := f.Names
263264
ft := f.Type
@@ -309,6 +310,7 @@ func processType(t *ast.TypeSpec) {
309310
"if n.%s != nil {\nn.%s = edit(n.%s).(%s%s)\n}\n", name, name, name, ptr, ft)
310311
}
311312
if hidden {
313+
hasHidden = true
312314
continue
313315
}
314316
if isSlice {
@@ -327,19 +329,27 @@ func processType(t *ast.TypeSpec) {
327329
}
328330
fmt.Fprintf(&buf, "func (n *%s) copy() Node {\nc := *n\n", name)
329331
buf.WriteString(copyBody.String())
330-
fmt.Fprintf(&buf, "return &c\n}\n")
332+
buf.WriteString("return &c\n}\n")
331333
fmt.Fprintf(&buf, "func (n *%s) doChildren(do func(Node) bool) bool {\n", name)
332334
buf.WriteString(doChildrenBody.String())
333-
fmt.Fprintf(&buf, "return false\n}\n")
335+
buf.WriteString("return false\n}\n")
334336
fmt.Fprintf(&buf, "func (n *%s) doChildrenWithHidden(do func(Node) bool) bool {\n", name)
335-
buf.WriteString(doChildrenWithHiddenBody.String())
336-
fmt.Fprintf(&buf, "return false\n}\n")
337+
if hasHidden {
338+
buf.WriteString(doChildrenWithHiddenBody.String())
339+
buf.WriteString("return false\n}\n")
340+
} else {
341+
buf.WriteString("return n.doChildren(do)\n}\n")
342+
}
337343
fmt.Fprintf(&buf, "func (n *%s) editChildren(edit func(Node) Node) {\n", name)
338344
buf.WriteString(editChildrenBody.String())
339-
fmt.Fprintf(&buf, "}\n")
345+
buf.WriteString("}\n")
340346
fmt.Fprintf(&buf, "func (n *%s) editChildrenWithHidden(edit func(Node) Node) {\n", name)
341-
buf.WriteString(editChildrenWithHiddenBody.String())
342-
fmt.Fprintf(&buf, "}\n")
347+
if hasHidden {
348+
buf.WriteString(editChildrenWithHiddenBody.String())
349+
} else {
350+
buf.WriteString("n.editChildren(edit)\n")
351+
}
352+
buf.WriteString("}\n")
343353
}
344354

345355
func generateHelpers() {

0 commit comments

Comments
 (0)