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/cgo: pthread_create failed: Resource temporarily unavailable #49057

Closed
justkeepsimple opened this issue Oct 19, 2021 · 5 comments
Closed
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@justkeepsimple
Copy link

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

go version go1.13.3 linux/amd64

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

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go-workspace"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build621629647=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Invoking blocking syscall function with goroutine;
When the Go process invokes the C function, it occupies an independent system thread. Therefore, if the C function is invoked concurrently in the Go program and the C function has blocking operations, the Go program may continuously create new system threads. However, the Go program does not recycle system threads.
How did i do to let the Go program to recycle system threads?

@davecheney
Copy link
Contributor

@justkeepsimple sadly Go 1.13 is no longer supported. Please upgrade to Go 1.17 and let us know if you still see the problem. Thanks

@davecheney davecheney added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 19, 2021
@justkeepsimple
Copy link
Author

justkeepsimple commented Oct 19, 2021

@justkeepsimple sadly Go 1.13 is no longer supported. Please upgrade to Go 1.17 and let us know if you still see the problem. Thanks

The problem persists after the new version(1.17.2) is compiled and run. @davecheney

@justkeepsimple
Copy link
Author

justkeepsimple commented Oct 19, 2021

@davecheney
after invoking C function, Call the function immediately.
func KillOne() {
var wg sync.WaitGroup
wg.Add(1)

go func() {
	defer wg.Done()
	runtime.LockOSThread()
	return
}()

wg.Wait()

}
It seems to be working!

@cherrymui
Copy link
Member

However, the Go program does not recycle system threads.

Could you show a code example? Why do you think it doesn't? Thanks.

@seankhliao
Copy link
Member

No new information

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jun 12, 2022
@golang golang locked and limited conversation to collaborators Jun 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants