]> Cypherpunks.ru repositories - gostls13.git/commit
syscall: treat proc thread attribute lists as unsafe.Pointers
authorJason A. Donenfeld <Jason@zx2c4.com>
Sun, 28 Feb 2021 11:18:18 +0000 (12:18 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 4 Mar 2021 19:59:23 +0000 (19:59 +0000)
commit77505c25d83a2130011736d6a2a915eaa3ae230a
tree2d5c6a161512e47c7ae356a36aadad6e37cdafc7
parent9d88a9e2bf89068238ed02a0c960e58f547bb102
syscall: treat proc thread attribute lists as unsafe.Pointers

It turns out that the proc thread update function doesn't actually
allocate new memory for its arguments and instead just copies the
pointer values into the preallocated memory. Since we were allocating
that memory as []byte, the garbage collector didn't scan it for pointers
to Go allocations and freed them. We _could_ fix this by requiring that
all users of this use runtime.KeepAlive for everything they pass to the
update function, but that seems harder than necessary. Instead, we can
just do the allocation as []unsafe.Pointer, which means the GC can
operate as intended and not free these from beneath our feet. In order
to ensure this remains true, we also add a test for this.

Fixes #44662.

Change-Id: Ib392ba8ceacacec94b11379919c8179841cba29f
Reviewed-on: https://go-review.googlesource.com/c/go/+/297389
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/syscall/exec_windows.go
src/syscall/export_windows_test.go [new file with mode: 0644]
src/syscall/syscall_windows.go
src/syscall/syscall_windows_test.go
src/syscall/types_windows.go
src/syscall/zsyscall_windows.go