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/http: data race in test #4329

Closed
dvyukov opened this issue Nov 1, 2012 · 5 comments
Closed

net/http: data race in test #4329

dvyukov opened this issue Nov 1, 2012 · 5 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Nov 1, 2012

I've added instrumentation to syscall.Sendfile(), so that it synchronizes with
syscall.Read(), but race builder still shows a race.
It's either another bug in race detector, or bug in the test.
What is strange is that race detector detector says that fd.close() happened before
Sendfile() according to wall clock time. It means that something really weird happens in
the test.


http://build.golang.org/log/bf2017abd5123b784f65272a7cc3eb8f1ccf3e13

WARNING: DATA RACE
Read by goroutine 142:
  net.sendFile()
      /usr/local/go/src/pkg/net/sendfile_linux.go:47 +0x5da
  net.(*TCPConn).ReadFrom()
      /usr/local/go/src/pkg/net/tcpsock_posix.go:80 +0x49
  net/http.(*response).ReadFrom()
      /usr/local/go/src/pkg/net/http/server.go:161 +0x11c
  io.CopyN()
      /usr/local/go/src/pkg/io/io.go:305 +0x1a0
  net/http.serveContent()
      /usr/local/go/src/pkg/net/http/fs.go:236 +0xaa0
  net/http.ServeContent()
      /usr/local/go/src/pkg/net/http/fs.go:118 +0x184
  net/http_test.func·024()
      /usr/local/go/src/pkg/net/http/fs_test.go:551 +0x19f
  ??()
      -:0 +0x401038a1
  net/http/httptest.(*waitGroupHandler).ServeHTTP()
      /usr/local/go/src/pkg/net/http/httptest/server.go:180 +0xcb
  net/http.(*conn).serve()
      /usr/local/go/src/pkg/net/http/server.go:681 +0x7a7

Previous write by goroutine 15:
  os.(*file).close()
      /usr/local/go/src/pkg/os/file_unix.go:110 +0x15e
  os.(*File).Close()
      /usr/local/go/src/pkg/os/file_unix.go:99 +0x43
  net/http_test.TestServeContent()
      /usr/local/go/src/pkg/net/http/fs_test.go:626 +0x1710
  testing.tRunner()
      /usr/local/go/src/pkg/testing/testing.go:301 +0x8f

Goroutine 142 (running) created at:
  net/http.(*Server).Serve()
      /usr/local/go/src/pkg/net/http/server.go:1116 +0x45e

Goroutine 15 (running) created at:
  testing.RunTests()
      /usr/local/go/src/pkg/testing/testing.go:377 +0xa8b
  testing.Main()
      /usr/local/go/src/pkg/testing/testing.go:313 +0xcd
  main.main()
      net/http/_test/_testmain.go:301 +0xda
  runtime.main()
      /usr/local/go/src/pkg/runtime/proc.c:248 +0x91
@dvyukov
Copy link
Member Author

dvyukov commented Nov 1, 2012

Comment 1:

I can reproduce it locally in 1 of 50 runs. It still says that close() happens before
sendfile(), so it's not that detector misses some synchronization.
Does anybody see how it can happen?
It looks that DefaultClient.Do(req) does not wait for sendfile...

@dvyukov
Copy link
Member Author

dvyukov commented Nov 2, 2012

Comment 2:

Perhaps it's another reincarnation of https://golang.org/issue/4245

@dvyukov
Copy link
Member Author

dvyukov commented Nov 2, 2012

Comment 3:

Nope, it's real bug.

@dvyukov
Copy link
Member Author

dvyukov commented Nov 2, 2012

Comment 4:

http://golang.org/cl/6822072

@dvyukov
Copy link
Member Author

dvyukov commented Nov 2, 2012

Comment 5:

This issue was closed by revision 600de1f.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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