aboutsummaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2021-11-22 10:21:19 -0500
committerBryan C. Mills <bcmills@google.com>2021-11-22 18:55:55 +0000
commit2d7ae3fbd86d4b5471ac4044ece208b29cd0ef74 (patch)
treeaaee690dd0ab6f466e5df48dc4228b19e0a67bb2 /src/net
parent9e94cc3666cc5ff6ecf5930fb5da48ba62ad8080 (diff)
downloadgo-2d7ae3fbd86d4b5471ac4044ece208b29cd0ef74.tar.gz
go-2d7ae3fbd86d4b5471ac4044ece208b29cd0ef74.zip
net: diagnose unexpected nils in TestUnixAndUnixpacketServer
For #34611 Change-Id: I31894d58498b2c290ecceccfc004bc817f8969c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/366114 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/net')
-rw-r--r--src/net/server_test.go31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/net/server_test.go b/src/net/server_test.go
index 5192c1e0af..33d33b0337 100644
--- a/src/net/server_test.go
+++ b/src/net/server_test.go
@@ -7,7 +7,9 @@
package net
import (
+ "fmt"
"os"
+ "reflect"
"testing"
)
@@ -187,7 +189,34 @@ func TestUnixAndUnixpacketServer(t *testing.T) {
}
t.Fatal(err)
}
- defer os.Remove(c.LocalAddr().String())
+
+ // We really just want to defer os.Remove(c.LocalAddr().String()) here,
+ // but sometimes that panics due to a nil dereference on the
+ // solaris-amd64-oraclerel builder (https://golang.org/issue/34611).
+ // The source of the nil panic is not obvious because there are many
+ // nillable types involved, so we will temporarily inspect all of them to
+ // try to get a better idea of what is happening on that platform.
+ checkNils := func() {
+ if c == nil {
+ panic("Dial returned a nil Conn")
+ }
+ if rc := reflect.ValueOf(c); rc.Kind() == reflect.Pointer && rc.IsNil() {
+ panic(fmt.Sprintf("Dial returned a nil %T", c))
+ }
+ addr := c.LocalAddr()
+ if addr == nil {
+ panic(fmt.Sprintf("(%T).LocalAddr returned a nil Addr", c))
+ }
+ if raddr := reflect.ValueOf(addr); raddr.Kind() == reflect.Pointer && raddr.IsNil() {
+ panic(fmt.Sprintf("(%T).LocalAddr returned a nil %T", c, addr))
+ }
+ }
+ defer func() {
+ checkNils()
+ os.Remove(c.LocalAddr().String())
+ }()
+ checkNils()
+
defer c.Close()
trchs = append(trchs, make(chan error, 1))
go transceiver(c, []byte("UNIX AND UNIXPACKET SERVER TEST"), trchs[i])