diff options
author | Michael Anthony Knyszek <mknyszek@google.com> | 2021-11-03 18:18:18 +0000 |
---|---|---|
committer | Michael Knyszek <mknyszek@google.com> | 2021-11-04 01:44:54 +0000 |
commit | d9bb5f6f109a4342c52958f30acfc3f3d633ee4f (patch) | |
tree | 55f5901d9e6dd4770c1aaad4f98262934c56f556 /src/internal | |
parent | 240df188d67edc3df498a77bf99d3152244c14ab (diff) | |
download | go-d9bb5f6f109a4342c52958f30acfc3f3d633ee4f.tar.gz go-d9bb5f6f109a4342c52958f30acfc3f3d633ee4f.zip |
syscall: fix and document uses of RegEnumKeyEx
RegEnumKeyEx has an undocumented requirement that subsequent calls need
to be made from the same thread. This change documents that requirement
and fixes uses of it in std.
Fixes #49320.
Change-Id: I6d182227e22dd437996a878b3a978943f01b2d61
Reviewed-on: https://go-review.googlesource.com/c/go/+/361154
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/internal')
-rw-r--r-- | src/internal/syscall/windows/registry/key.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/internal/syscall/windows/registry/key.go b/src/internal/syscall/windows/registry/key.go index ba5c292c5e..ec38cf9288 100644 --- a/src/internal/syscall/windows/registry/key.go +++ b/src/internal/syscall/windows/registry/key.go @@ -25,7 +25,10 @@ // package registry -import "syscall" +import ( + "runtime" + "syscall" +) const ( // Registry key security and access rights. @@ -88,6 +91,12 @@ func OpenKey(k Key, path string, access uint32) (Key, error) { // ReadSubKeyNames returns the names of subkeys of key k. func (k Key) ReadSubKeyNames() ([]string, error) { + // RegEnumKeyEx must be called repeatedly and to completion. + // During this time, this goroutine cannot migrate away from + // its current thread. See #49320. + runtime.LockOSThread() + defer runtime.UnlockOSThread() + names := make([]string, 0) // Registry key size limit is 255 bytes and described there: // https://msdn.microsoft.com/library/windows/desktop/ms724872.aspx |