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

cmd/go: slice bounds out of range in test #14337

Closed
jucie opened this issue Feb 15, 2016 · 4 comments
Closed

cmd/go: slice bounds out of range in test #14337

jucie opened this issue Feb 15, 2016 · 4 comments
Milestone

Comments

@jucie
Copy link

jucie commented Feb 15, 2016

go version devel +387d5b8 Sat Feb 13 17:33:22 2016 +0000 windows/amd64

It builds fine, but I got an error during test.

`##### Testing packages.
. . .
ok math/cmplx 0.609s
ok math/rand 0.350s
ok mime 2.359s
ok mime/multipart 5.000s
ok mime/quotedprintable 2.704s
panic: runtime error: slice bounds out of range

goroutine 14 [running]:
syscall.createEnvBlock(0xc082043400, 0x55, 0x68, 0xc082a0a1f0)
C:/go/src/syscall/exec_windows.go:115 +0x5b3
syscall.StartProcess(0xc082365180, 0x4c, 0xc0829e5aa0, 0x3, 0x3,

0xc082c136d0, 0x0, 0x0, 0x0, 0x0)
C:/go/src/syscall/exec_windows.go:326 +0x8b1
os.startProcess(0xc082365180, 0x4c, 0xc0829e5aa0, 0x3, 0x3, 0xc082c13928,

0x9d2e20, 0x0, 0x0)
C:/go/src/os/exec_posix.go:45 +0x345
os.StartProcess(0xc082365180, 0x4c, 0xc0829e5aa0, 0x3, 0x3, 0xc082c13928,

0x0, 0x0, 0x0)
C:/go/src/os/doc.go:28 +0x70
os/exec.(_Cmd).Start(0xc082cd8b40, 0x0, 0x0)
C:/go/src/os/exec/exec.go:332 +0x87e
main.(_builder).runTest(0xc0820eefc0, 0xc0829765b0, 0x0, 0x0)
C:/go/src/cmd/go/test.go:1107 +0xa2b
main.(_builder).do.func1(0xc0829765b0)
C:/go/src/cmd/go/build.go:1257 +0x3b9
main.(_builder).do.func2(0xc082abe710, 0xc0820eefc0, 0xc082740ea0)
C:/go/src/cmd/go/build.go:1314 +0x15d
created by main.(*builder).do
C:/go/src/cmd/go/build.go:1320 +0x3a5
2016/02/15 15:59:10 Failed: exit status 2
`
It happened only once. I tried to reproduce, to no avail. Next build was fine

@ianlancetaylor ianlancetaylor changed the title slice bounds out of range build: slice bounds out of range in test Feb 16, 2016
@ianlancetaylor
Copy link
Contributor

There should have been a bit more to the output that you did not include. Which package's tests failed?

@ianlancetaylor ianlancetaylor added this to the Go1.7 milestone Feb 16, 2016
@jucie
Copy link
Author

jucie commented Feb 16, 2016

It appears to me the error occurred when testing package net, Ian.

This is the full output from my terminal session:
goIssue14377.txt
panic is at line 407.
When I saw the error I opened vi to see the offending source line.
Right after, I inspected my environment variables then I tried to find a script to run tests only. Couldn't find.
Then I tried to build again (by running all.bat) and this time build & test succeeded.

Obs.: it seems test failure at line 940 is unrelated (TestEvalSymlinksCanonicalNames). Issue #13980.

Details about my development box:
OS Name: Microsoft Windows 8 Single Language
OS Version: 6.2.9200 N/A Build 9200
Intel64 Family 6 Model 58 Stepping 9 GenuineIntel ~2400 Mhz

@ianlancetaylor ianlancetaylor changed the title build: slice bounds out of range in test cmd/go: slice bounds out of range in test Feb 16, 2016
@ianlancetaylor
Copy link
Contributor

Thanks for the full log.

I think I see an unlikely race condition. In cmd/go, each test sets cmd.Env to the result of envForDir(cmd.Dir,envForDir(cmd.Dir, origEnv). The envForDir function calls mergeEnvLists, which appends to its second argument. Multiple tests are run in parallel. This means that there is a race condition changing the environment used to run the tests. On Windows, the environment is converted into a block of NUL-terminated strings by looping over the environment slice twice. A very precisely timed race could cause the environment slice to change between the two loops, which could cause this error.

I build a version of cmd/go using -race (go build -race -o gorace cmd/go) and then ran gorace test std. I got this, which is the race I am describing.

==================
WARNING: DATA RACE
Read by goroutine 14:
  main.mergeEnvLists()
      /home/iant/go/src/cmd/go/main.go:461 +0x1cc
  main.envForDir()
      /home/iant/go/src/cmd/go/main.go:452 +0x131
  main.(*builder).runTest()
      /home/iant/go/src/cmd/go/test.go:1077 +0x82b
  main.(*builder).do.func1()
      /home/iant/go/src/cmd/go/build.go:1257 +0x56f
  main.(*builder).do.func2()
      /home/iant/go/src/cmd/go/build.go:1314 +0x181

Previous write by goroutine 13:
  main.mergeEnvLists()
      /home/iant/go/src/cmd/go/main.go:463 +0x2aa
  main.envForDir()
      /home/iant/go/src/cmd/go/main.go:452 +0x131
  main.(*builder).runTest()
      /home/iant/go/src/cmd/go/test.go:1077 +0x82b
  main.(*builder).do.func1()
      /home/iant/go/src/cmd/go/build.go:1257 +0x56f
  main.(*builder).do.func2()
      /home/iant/go/src/cmd/go/build.go:1314 +0x181

Goroutine 14 (running) created at:
  main.(*builder).do()
      /home/iant/go/src/cmd/go/build.go:1320 +0x68e
  main.runTest()
      /home/iant/go/src/cmd/go/test.go:595 +0x33f3
  main.main()
      /home/iant/go/src/cmd/go/main.go:181 +0xa38

Goroutine 13 (running) created at:
  main.(*builder).do()
      /home/iant/go/src/cmd/go/build.go:1320 +0x68e
  main.runTest()
      /home/iant/go/src/cmd/go/test.go:595 +0x33f3
  main.main()
      /home/iant/go/src/cmd/go/main.go:181 +0xa38
==================

@ianlancetaylor ianlancetaylor self-assigned this Feb 16, 2016
@ianlancetaylor ianlancetaylor modified the milestones: Go1.6, Go1.7 Feb 16, 2016
@gopherbot
Copy link

CL https://golang.org/cl/19513 mentions this issue.

@golang golang locked and limited conversation to collaborators Feb 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants