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

"runtime: failed to create new OS thread" and "fatal error: runtime.newosproc" in Windows x86 #42253

Closed
tomasz1986 opened this issue Oct 28, 2020 · 2 comments

Comments

@tomasz1986
Copy link

tomasz1986 commented Oct 28, 2020

What version of Go are you using (go version)?

go version go1.15.1 windows/amd64

Does this issue reproduce with the latest release?

Not sure.

What operating system and processor architecture are you using (go env)?

go env Output
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\User\AppData\Local\go-build
set GOENV=C:\Users\User\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\User\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\User\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\User\AppData\Local\Temp\go-build574354070=/tmp/go-build -gno-record-gcc-switches

Edit: I just wanted to add that the Go version and OS/CPU listed here are of the machine where the program was compiled, not where the crash occurred. The specs of the latter are listed in the explanation below.

What did you do?

First of all, I am not a professional developer/programmer, so please bear with me. I had Syncthing, a program written in Golang, crash with the following panic logs.

runtime: failed to create new OS thread (have 1192 already; errno=8)
Panic at 2020-10-28T21:25:20+09:00
fatal error: runtime.newosproc

runtime stack:
runtime.throw(0x120fa12, 0x11)
	runtime/panic.go:1116 +0x64
runtime.newosproc(0x17ecafc0)
	runtime/os_windows.go:794 +0x146
runtime.newm1(0x17ecafc0)
	runtime/proc.go:1829 +0xbd
runtime.newm(0x13e5b7c, 0x12c2c000, 0x4a7, 0x0)
	runtime/proc.go:1808 +0x81
runtime.startm(0x12c2c000, 0x1)
	runtime/proc.go:1965 +0xac
runtime.handoffp(0x12c2c000)
	runtime/proc.go:2004 +0x28c
runtime.retake(0x68d8ec28, 0x4587, 0x0)
	runtime/proc.go:4805 +0x171
runtime.sysmon()
	runtime/proc.go:4713 +0x275
runtime.mstart1()
	runtime/proc.go:1172 +0x9b
runtime.mstart()
	runtime/proc.go:1137 +0x51

panic-20201028-212520.log

I had reported the problem on the Syncthing issue tracker (syncthing/syncthing#7064), but it was suggested that it might be either a problem with the Go runtime, or the OS.

The problem has occurred only once so far, so I cannot reproduce it at will. I am guessing that it may be related to https://devblogs.microsoft.com/oldnewthing/?p=34773. The machine runs Windows 10 Enterprise 2016 LTSB x86, and Syncthing is also x86-32.

I am suspecting that the issue may be related to the 2000 threads per process limitation in 32-bit installations of Windows explained by Microsoft in the link above, but this is just a guess.

Is this problem something that can be "fixed" or tweaked in the code (using Microsoft's words), or is it just a limitation of Go running under the 32-bit Windows?

@ianlancetaylor
Copy link
Contributor

We don't use the issue tracker for help requests. You will get better and faster answers if you use a forum. Please see https://golang.org/wiki/Questions. Thanks.

In this case the first question would be: why so many threads? The answer to that would depend on what your program is doing. But, again, please raise these issues in a forum. Thanks.

@golang golang locked and limited conversation to collaborators Oct 29, 2021
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