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

syscall: data race in LazyDLL/LazyProc #4343

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

syscall: data race in LazyDLL/LazyProc #4343

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

Comments

@dvyukov
Copy link
Member

@dvyukov dvyukov commented Nov 5, 2012

Revision 14791. Experimental windows race detector says:

WARNING: DATA RACE
Read by goroutine 3:
  syscall.(*LazyProc).Addr()
      src/pkg/syscall/dll_windows.go:252 +0x6e
  syscall.CloseHandle()
      src/pkg/syscall/zsyscall_windows_amd64.go:302 +0x5b
  os.(*file).close()
      src/pkg/os/file_windows.go:147 +0x230
  os.(*File).Close()
      src/pkg/os/file_windows.go:136 +0x46
  debug/pe.Open()
      src/pkg/debug/pe/file.go:104 +0xe0
  debug/pe.TestOpenFailure()
      src/pkg/debug/pe/file_test.go:123 +0x4e
  testing.tRunner()
      src/pkg/testing/testing.go:301 +0x92

Previous write by goroutine 4:
  syscall.(*DLL).FindProc()
      src/pkg/syscall/dll_windows.go:85 +0x35a
  syscall.(*LazyProc).Find()
      src/pkg/syscall/dll_windows.go:230 +0x158
  syscall.(*LazyProc).mustFind()
      src/pkg/syscall/dll_windows.go:242 +0x35
  syscall.(*LazyProc).Addr()
      src/pkg/syscall/dll_windows.go:251 +0x35
  syscall.CloseHandle()
      src/pkg/syscall/zsyscall_windows_amd64.go:302 +0x5b
  os.(*file).close()
      src/pkg/os/file_windows.go:147 +0x230
  runfinq()
      src/pkg/runtime/mgc0.c:1170 +0x13d

Goroutine 3 (running) created at:
  testing.RunTests()
      src/pkg/testing/testing.go:377 +0xafb
  testing.Main()
      src/pkg/testing/testing.go:313 +0xd0
  main.main()
      _testmain.go:45 +0xdd
  runtime.main()
      src/pkg/runtime/proc.c:248 +0x94

Goroutine 4 (running) created at:
  runtime.gc()
      src/pkg/runtime/mgc0.c:961 +0x0
  os.OpenFile()
      src/pkg/os/file_windows.go:118 +0x1b7
  os.Open()
      src/pkg/os/file.go:230 +0x65
  debug/pe.Open()
      src/pkg/debug/pe/file.go:98 +0x3f
  debug/pe.TestOpenFailure()
      src/pkg/debug/pe/file_test.go:123 +0x4e
@dvyukov
Copy link
Member Author

@dvyukov dvyukov commented Nov 5, 2012

Comment 1:

Both LazyDLL and LazyProc contain unsafe double-checked locking.
I have a fix which uses atomics:
https://golang.org/cl/6817086/diff/2001/src/pkg/syscall/dll_windows.go
It's ugly. I can't figure out how to use sync.Once efficiently here. There is no
"constructor" for LazyProc, so I can't even put additional func into it...
@dvyukov
Copy link
Member Author

@dvyukov dvyukov commented Nov 16, 2012

Comment 2:

This issue was closed by revision 9b4aaa4.

Status changed to Fixed.

@dvyukov dvyukov added fixed labels Nov 16, 2012
@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.