-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
x/vuln/cmd/govulncheck: consuming 90%+ of memory and runs without an end #67838
Comments
Can you clarify this point? |
cc @zpavlinovic |
Yes, that is correct. It completes in a reasonable timeframe with go 1.21.11 and with 1.21.10 it takes at least 30 minutes (after that the govulncheck was killed). I suspect it is because 1.21.11 is just out this week and has no vulnerabilities in the database. |
I tried to build a container image in which the issue can be replicated but so far without success. |
What results do you get with go1.21.11, It seems you are able to get a result with go1.21.10 on your local machine. How much time does that take? (Note that you are invoking govulncheck in its default mode where it tries to build a call graph and find a call stack to the vulnerable symbols. This will take time and memory for large projects with many dependencies) |
The results of govulncheck with go1.21.11 in the container on the build server are:
When I run it with 1.22.10 on my local machine (32GB RAM + intel i7-12800H multicore) it reports:
|
It looks that both of those runs finished within reasonable times. Could you also provide the results on running with go1.21.11 but on your local machine? |
Sure. See below:
|
On your local machine, both go1.21.10 and go1.21.11 finish rather quickly. go1.21.11 is somewhat faster. My hunch is that in this case there are no vulnerabilities that apply to your code at all and govulncheck can take a fast path out. (A signal for this is that GO-2024-2887 is fixed in 1.21.11.) What is interesting is that it takes ~13x more time for go1.21.11 to finish in the container compared to the local machine. govulncheck integration tests (cmd/govulncheck/integration) run govulncheck in a container on k8s source code and on a binary built from a certain repo. Building the container, cloning the k8s and the other repo, building govulncheck and the test binary, and then finally running govulncheck takes in total 3.5 minutes. (We've observed similar times with different go versions in the container). That suggests that the issue you are seeing is related to your container setup. |
Can it be that the resources (RAM+CPU) are insufficient for the buildserver? I think that when it starts swapping, it does not finish the job in a reasonable timeframe. |
That could be the case for really very large programs with plenty dependencies, but I am still a little bit surprised by the numbers. You can play with this by running govulncheck in the container for a specific package of your module (instead of ./...) and see if things are faster. If increasing RAM on your builder is not an option, note that you can also run govulncheck with |
This application has quite a few dependencies. |
govulncheck will first get vulnerabilities for your dependencies from the database. If there are no vulnerabilities for your dependencies or you are not depending on them at a vulnerable version, govulncheck will exit without creating a call graph. |
I did not know that. Thanks for explaining. Tomorrow I will add more resources to the buildserver and I would expect it to run fine. I will close the issue unless I see something strange. Thanks for the great support. It was very helpful. |
After doubling the RAM from 4 to 8 GB (still with 1 CPU) the vulncheck finished just under 2 minutes:
I will close the issue. It would be nice to have the check consumes less memory. Before this issue popped up, the build server only had 2GB of RAM. |
@ArnoSen 8Gb is a bit higher than we want folks to need to set limits on CI/CD pipelines. If you have precise reproducer instructions, we could use that to see if there are any improvements we can make for memory consumption. No guarantees on whether we will do this or when it might happen. But if we have a reproducer that is a much clearer starting point if this gets off the back burner. |
I cannot share the code so I am afraid that limits your ability to exactly reproduce the vulnerability checks memory consumption. Is there anything I can help you with in that case? Maybe some profiling data? |
govulncheck version
In my script I am using 'latest' which resolves to v1.1.1
Does this issue reproduce at the latest version of golang.org/x/vuln?
Yes
Output of
go env
in your module/workspace:What did you do?
I using gitlab CI/CD with a runner that runs in Docker and then spins up a new image (docker in docker).
In this case govulncheck runs in a container with image "golang:1.21.10" .
During the build, the following command is executed:
$ go run golang.org/x/vuln/cmd/govulncheck@latest ./...
What did you see happen?
I noticed the vulnerability check takes very long and looks like it never finishes
Upon inspection of the container the memory usage is +90% . The build server has 4GB of mem and govulncheck takes over 3GB. It let it run for over 6 minutes but it did not produce any result.
What did you expect to see?
I expect it to finish it with an acceptable time and not consume over 90% of memory.
What makes this behavior particularly strange is that this seems to happen when a new Go (minor) version is released: when I run the pipeline with "golang:1.21.11", the vulnerability check finishes in less than 20s.
I suspect this has go to do with the fact that there is a finding.
When I run govulncheck from my local machine on the same project I do get a report of issues found:
$go version
go version go1.21.10 linux/amd64
$ $ go run golang.org/x/vuln/cmd/govulncheck@latest ./...
The text was updated successfully, but these errors were encountered: