From: Mateusz Poliwczak Date: Thu, 17 Nov 2022 08:54:48 +0000 (+0000) Subject: net: call getSystemDNSConfig inside lookupWithFake to avoid nil dereference panic... X-Git-Tag: go1.21rc1~1151 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=478b1d260a21a83a090ba120efb79753495545e1;p=gostls13.git 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 --- 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()