From 478b1d260a21a83a090ba120efb79753495545e1 Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Thu, 17 Nov 2022 08:54:48 +0000 Subject: [PATCH] net: call getSystemDNSConfig inside lookupWithFake to avoid nil dereference panic when running tests alone It happens with tests that only call lookupWithFake, and before them no-one calls resolverConf.tryUpdate. running alone one of these: TestIssue8434, TestIssueNoSuchHostExists cause a nil dereference panic. Change-Id: I3fccd96dff5b3c77b5420a7f73742acbafa80142 GitHub-Last-Rev: 7456fd16a7ff4845b4ca305d4107d29f1d6f7b3e GitHub-Pull-Request: golang/go#56759 Reviewed-on: https://go-review.googlesource.com/c/go/+/450856 TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Damien Neil --- src/net/dnsclient_unix_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/dnsclient_unix_test.go b/src/net/dnsclient_unix_test.go index 0def954f8c..6deeb39104 100644 --- a/src/net/dnsclient_unix_test.go +++ b/src/net/dnsclient_unix_test.go @@ -1443,7 +1443,7 @@ func TestDNSGoroutineRace(t *testing.T) { func lookupWithFake(fake fakeDNSServer, name string, typ dnsmessage.Type) error { r := Resolver{PreferGo: true, Dial: fake.DialContext} - conf := resolvConf.dnsConfig.Load() + conf := getSystemDNSConfig() ctx, cancel := context.WithCancel(context.Background()) defer cancel() -- 2.50.0