Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: TestDNSNameLength panics when running it alone #56542

Closed
mateusz834 opened this issue Nov 3, 2022 · 3 comments
Closed

net: TestDNSNameLength panics when running it alone #56542

mateusz834 opened this issue Nov 3, 2022 · 3 comments

Comments

@mateusz834
Copy link
Member

mateusz834 commented Nov 3, 2022

[mateusz@arch src]$ go version
go version devel go1.20-2af48cbb7d Thu Nov 3 12:16:35 2022 +0000 linux/amd64

While running go test net I don't get any failures, but when I only run the TestDNSNameLength, it panics.

[mateusz@arch src]$ go test -run=DNSNameLen -v net
=== RUN   TestDNSNameLength
--- FAIL: TestDNSNameLength (0.00s)
panic: runtime error: slice bounds out of range [1:0] [recovered]
	panic: runtime error: slice bounds out of range [1:0]

goroutine 6 [running]:
testing.tRunner.func1.2({0x677700, 0xc00001e510})
	/home/mateusz/code/go/src/testing/testing.go:1512 +0x24e
testing.tRunner.func1()
	/home/mateusz/code/go/src/testing/testing.go:1515 +0x39f
panic({0x677700, 0xc00001e510})
	/home/mateusz/code/go/src/runtime/panic.go:884 +0x213
net.TestDNSNameLength(0xc00011c4e0)
	/home/mateusz/code/go/src/net/dnsconfig_unix_test.go:298 +0x539
testing.tRunner(0xc00011c4e0, 0x6a0f40)
	/home/mateusz/code/go/src/testing/testing.go:1562 +0x10b
created by testing.(*T).Run
	/home/mateusz/code/go/src/testing/testing.go:1611 +0x3df
FAIL	net	0.005s
FAIL
@mateusz834
Copy link
Member Author

mateusz834 commented Nov 3, 2022

It does not panic when I run these two tests in a row:

go test -run="DNSReadConfig|DNSNameLength" -v net

@mateusz834
Copy link
Member Author

It probably happens because we modify the shared variable here:

for _, tt := range dnsReadConfigTests {
if len(tt.want.search) == 0 {
tt.want.search = append(tt.want.search, dnsDefaultSearch()...)
}
conf := dnsReadConfig(tt.name)

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/447198 mentions this issue: net: do not modify shared test variable in TestDNSReadConfig

romaindoumenc pushed a commit to TroutSoftware/go that referenced this issue Nov 3, 2022
Fixes golang#56542

Change-Id: I294856f8fb4d49393310ec92ab40fb7d841b6570
GitHub-Last-Rev: a456340
GitHub-Pull-Request: golang#56545
Reviewed-on: https://go-review.googlesource.com/c/go/+/447198
Reviewed-by: Bryan Mills <[email protected]>
Run-TryBot: Bryan Mills <[email protected]>
Auto-Submit: Bryan Mills <[email protected]>
Reviewed-by: Matthew Dempsky <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
@golang golang locked and limited conversation to collaborators Nov 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants