coder icon indicating copy to clipboard operation
coder copied to clipboard

bug: TestDERPEndToEnd : NPE if nil Region in derpmap

Open johnstcn opened this issue 2 years ago • 1 comments

Seen here: https://github.com/coder/coder/actions/runs/7206571800/job/19631681483

2023-12-14T09:01:17.9425955Z     t.go:84: 2023-12-14 09:00:51.289 [debu]  servertailnet: updating derp map  derp_map="&{HomeParams:<nil> Regions:map[10001:<nil>] OmitDefaultRegions:true}"
2023-12-14T09:01:17.9427048Z     t.go:84: 2023-12-14 09:00:51.289 [debu]  servertailnet.net.wgengine: magicsock: closing connection to derp-999 (derp-region-redefined), age 5s
2023-12-14T09:01:17.9427853Z     t.go:84: 2023-12-14 09:00:51.289 [debu]  servertailnet.net.wgengine: magicsock: 0 active derp conns
2023-12-14T09:01:17.9428485Z     t.go:84: 2023-12-14 09:00:51.289 [debu]  servertailnet: updating network map
2023-12-14T09:01:17.9429643Z     t.go:84: 2023-12-14 09:00:51.289 [debu]  servertailnet.net.netstack: [v2] netstack: registered IP fd7a:115c:a1e0:4713:8699:733c:9786:1b27/128
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x10b890d]

goroutine 74133 [running]:
tailscale.com/net/netcheck.sortRegions(0xc093820c18, 0xc08cc5a9a0)
	/home/runner/go/pkg/mod/github.com/coder/[email protected]/net/netcheck/netcheck.go:379 +0xed
tailscale.com/net/netcheck.makeProbePlan(0xc093f2af88?, 0xc095118d20?, 0xc08cc5a9a0)
	/home/runner/go/pkg/mod/github.com/coder/[email protected]/net/netcheck/netcheck.go:422 +0xea
tailscale.com/net/netcheck.(*Client).GetReport(0xc088053c80, {0x3af14a8, 0xc08d8bd6c0}, 0xc093820c18)
	/home/runner/go/pkg/mod/github.com/coder/[email protected]/net/netcheck/netcheck.go:981 +0xfde
tailscale.com/wgengine/magicsock.(*Conn).updateNetInfo(0xc08a069500, {0x3af[1438](https://github.com/coder/coder/actions/runs/7206571800/job/19631681483#step:5:1439), 0xc08d75ccd0})
	/home/runner/go/pkg/mod/github.com/coder/[email protected]/wgengine/magicsock/magicsock.go:642 +0x1e5
tailscale.com/wgengine/magicsock.(*Conn).determineEndpoints(0xc08a069500, {0x3af1438, 0xc08d75ccd0})
	/home/runner/go/pkg/mod/github.com/coder/[email protected]/wgengine/magicsock/magicsock.go:840 +0x85
tailscale.com/wgengine/magicsock.(*Conn).updateEndpoints(0xc08a069500, {0x2bfdf54, 0xf})
	/home/runner/go/pkg/mod/github.com/coder/[email protected]/wgengine/magicsock/magicsock.go:549 +0x249
created by tailscale.com/wgengine/magicsock.(*Conn).ReSTUN in goroutine 74131
	/home/runner/go/pkg/mod/github.com/coder/[email protected]/wgengine/magicsock/magicsock.go:2215 +0x3ee

Context in netcheck.go:

// sortRegions returns the regions of dm first sorted
// from fastest to slowest (based on the 'last' report),
// end in regions that have no data.
func sortRegions(dm *tailcfg.DERPMap, last *Report) (prev []*tailcfg.DERPRegion) {
	prev = make([]*tailcfg.DERPRegion, 0, len(dm.Regions))
	for _, reg := range dm.Regions {
		if reg.Avoid {             // <-- explosion here
			continue
		}
		prev = append(prev, reg)
	}

Full logs: https://gist.githubusercontent.com/johnstcn/92a7072357eb780902d4c95f595e3af2/raw/8c936013855c1db7fa9e0a911e95cdb27ca00fbd/gistfile1.txt

johnstcn avatar Dec 14 '23 09:12 johnstcn

Seen here: https://github.com/coder/coder/actions/runs/7251451714/job/19753848741#step:5:849

johnstcn avatar Dec 18 '23 17:12 johnstcn