Skip to content

gopls: spawns cc1 processes on file save when using imports that use cgo and chews up machine resources #3395

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

Closed
mintsoft opened this issue May 19, 2024 · 2 comments

Comments

@mintsoft
Copy link

What version of Go, VS Code & VS Code Go extension are you using?

Go 1.21, vscode 1.89.1.24130, Extension: v0.41.4
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.21.6 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
Build info
----------
golang.org/x/tools/gopls v0.15.3
    golang.org/x/tools/[email protected] h1:zbdOidFrPTc8Bx0YrN5QKgJ0zCjyGi0L27sKQ/bDG5o=
    github.com/BurntSushi/[email protected] h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/[email protected] h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
    golang.org/x/exp/[email protected] h1:2O2DON6y3XMJiQRAS1UWU+54aec2uopH3x7MAiqGW6Y=
    golang.org/x/[email protected] h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
    golang.org/x/[email protected] h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
    golang.org/x/[email protected] h1:vcVnuftN4J4UKLRcgetjzfU9FjjgXUUYUc3JhFplgV4=
    golang.org/x/[email protected] h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
    golang.org/x/[email protected] h1:uH9jJYgeLCvblH0S+03kFO0qUDxRkbLRLFiKVVDl7ak=
    golang.org/x/[email protected] h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU=
    honnef.co/go/[email protected] h1:oFEHCKeID7to/3autwsWfnuv69j3NsfcXbvJKuIcep8=
    mvdan.cc/[email protected] h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
    mvdan.cc/xurls/[email protected] h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.21.6
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • Version: 1.89.1
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.41.4
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
# Tools Configuration


## Environment

GOBIN: undefined
toolsGopath: 
gopath: /home/rob/go
GOROOT: /usr/local/go
PATH: /home/rob/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin

## Tools

	go:	/usr/local/go/bin/go: go version go1.21.6 linux/amd64

	gopls:	/home/rob/go/bin/gopls	(version: v0.15.3 built with go: go1.21.6)
	gotests:	not installed
	gomodifytags:	not installed
	impl:	not installed
	goplay:	not installed
	dlv:	not installed
	staticcheck:	/home/rob/go/bin/staticcheck	(version: v0.4.7 built with go: go1.21.6)

## Go env

Workspace Folder (laptop-client): /home/rob/Documents/code/VScode-Golang_bug/laptop-client

	GO111MODULE=''
	GOARCH='amd64'
	GOBIN=''
	GOCACHE='/home/rob/.cache/go-build'
	GOENV='/home/rob/.config/go/env'
	GOEXE=''
	GOEXPERIMENT=''
	GOFLAGS=''
	GOHOSTARCH='amd64'
	GOHOSTOS='linux'
	GOINSECURE=''
	GOMODCACHE='/home/rob/go/pkg/mod'
	GONOPROXY=''
	GONOSUMDB=''
	GOOS='linux'
	GOPATH='/home/rob/go'
	GOPRIVATE=''
	GOPROXY='https://proxy.golang.org,direct'
	GOROOT='/usr/local/go'
	GOSUMDB='sum.golang.org'
	GOTMPDIR=''
	GOTOOLCHAIN='auto'
	GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
	GOVCS=''
	GOVERSION='go1.21.6'
	GCCGO='gccgo'
	GOAMD64='v1'
	AR='ar'
	CC='gcc'
	CXX='g++'
	CGO_ENABLED='1'
	GOMOD='/home/rob/Documents/code/VScode-Golang_bug/laptop-client/go.mod'
	GOWORK=''
	CGO_CFLAGS='-O2 -g'
	CGO_CPPFLAGS=''
	CGO_CXXFLAGS='-O2 -g'
	CGO_FFLAGS='-O2 -g'
	CGO_LDFLAGS='-O2 -g'
	PKG_CONFIG='pkg-config'
	GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2404829933=/tmp/go-build -gno-record-gcc-switches'
	

Share the Go related settings you have added/edited

None

Describe the bug

I am running into a problem very similiar to #268. If I open a project using cgo and work on it, it seems like every time I save I amass a cc1 process that is using 1 core and does not seem to ever go away. I will provide a small project that it happens on shortly. It happens on multiple computers and not all projects, so I'm pretty sure it's something to do with cgo.

Steps to reproduce the behavior:

  1. Open project importing a cgo library
  2. Make minor changes 4 or 5 times and save each time
  3. See many cc1 processes spawned and using large amounts of CPU.
  4. Wait to see if they go away....

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

@gopherbot gopherbot added this to the Untriaged milestone May 19, 2024
@mintsoft
Copy link
Author

OK the project that was a major culprit for it before now isn't doing it so I've not got an easy example at the moment. The next time it happens I'll see if I can gather some relevant information

@hyangah
Copy link
Contributor

hyangah commented May 23, 2024

Thanks for filing issues. @mintsoft

Duplicate of golang/go#50151
If you find a sharable example, can you please share it in the issue? Thank you so much.

@hyangah hyangah closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2024
@golang golang locked and limited conversation to collaborators May 23, 2025
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