Skip to content

Commit e93f439

Browse files
committed
runtime/cgo: retry when CreateThread fails with ERROR_ACCESS_DENIED
_cgo_beginthread used to retry _beginthread only when it failed with EACCESS, but CL 651995 switched to CreateThread and incorrectly mapped EACCESS to ERROR_NOT_ENOUGH_MEMORY. The correct mapping is ERROR_ACCESS_DENIED. Fixes golang#72814 Fixes golang#75381 Change-Id: I8ba060114aae4e8249576f11a21eff613caa8001 Reviewed-on: https://go-review.googlesource.com/c/go/+/706075 Reviewed-by: Michael Pratt <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent 69e74b0 commit e93f439

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/runtime/cgo/gcc_libinit_windows.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void _cgo_beginthread(unsigned long (__stdcall *func)(void*), void* arg) {
145145

146146
for (tries = 0; tries < 20; tries++) {
147147
thandle = CreateThread(NULL, 0, func, arg, 0, NULL);
148-
if (thandle == 0 && GetLastError() == ERROR_NOT_ENOUGH_MEMORY) {
148+
if (thandle == 0 && GetLastError() == ERROR_ACCESS_DENIED) {
149149
// "Insufficient resources", try again in a bit.
150150
//
151151
// Note that the first Sleep(0) is a yield.

0 commit comments

Comments
 (0)