File tree 1 file changed +30
-1
lines changed 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 7
7
package net
8
8
9
9
import (
10
+ "fmt"
10
11
"os"
12
+ "reflect"
11
13
"testing"
12
14
)
13
15
@@ -187,7 +189,34 @@ func TestUnixAndUnixpacketServer(t *testing.T) {
187
189
}
188
190
t .Fatal (err )
189
191
}
190
- defer os .Remove (c .LocalAddr ().String ())
192
+
193
+ // We really just want to defer os.Remove(c.LocalAddr().String()) here,
194
+ // but sometimes that panics due to a nil dereference on the
195
+ // solaris-amd64-oraclerel builder (https://golang.org/issue/34611).
196
+ // The source of the nil panic is not obvious because there are many
197
+ // nillable types involved, so we will temporarily inspect all of them to
198
+ // try to get a better idea of what is happening on that platform.
199
+ checkNils := func () {
200
+ if c == nil {
201
+ panic ("Dial returned a nil Conn" )
202
+ }
203
+ if rc := reflect .ValueOf (c ); rc .Kind () == reflect .Pointer && rc .IsNil () {
204
+ panic (fmt .Sprintf ("Dial returned a nil %T" , c ))
205
+ }
206
+ addr := c .LocalAddr ()
207
+ if addr == nil {
208
+ panic (fmt .Sprintf ("(%T).LocalAddr returned a nil Addr" , c ))
209
+ }
210
+ if raddr := reflect .ValueOf (addr ); raddr .Kind () == reflect .Pointer && raddr .IsNil () {
211
+ panic (fmt .Sprintf ("(%T).LocalAddr returned a nil %T" , c , addr ))
212
+ }
213
+ }
214
+ defer func () {
215
+ checkNils ()
216
+ os .Remove (c .LocalAddr ().String ())
217
+ }()
218
+ checkNils ()
219
+
191
220
defer c .Close ()
192
221
trchs = append (trchs , make (chan error , 1 ))
193
222
go transceiver (c , []byte ("UNIX AND UNIXPACKET SERVER TEST" ), trchs [i ])
You can’t perform that action at this time.
0 commit comments