-
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
valgrind fails #60600
Comments
Go doesn't support valgrind, but does support asan, msan, and tsan, which work with clang, and perhaps gcc. |
Yes, I notice. That is why I open the ticket. |
What happens if you run valgrind on a Go program linked with C libraries? I would expect it to check the memory behavior of the C code. |
Exactly, and without errors from I can give an example Now I run it with
I am obviously not interested in errors in go, but can you assure me that my C++ library is cleared? I run |
Thanks. This will need attention from somebody familiar with valgrind. The memory is initialized, but valgrind doesn't seem to know that. I don't know why. |
I don't know if this will help but I've used valgrind a few times with Go on ppc64le, and I usually have to build the Go binary with external linking to get it to work. I'm not sure why, maybe valgrind depends on something in __libc_start_main. Since you are seeing runtime.rt0_go I believe that means it was built with the internal linker. |
That might be that, then perhaps |
If your Go package use cgo, which is the normal way for Go code to call C code, then you will be using external linking by default. |
I do understand your point. |
Ian's point is that my suggestion won't help. |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
I have no idea what additional information you need. |
Reopening. But as we said before, this is going to require attention from somebody familiar with valgrind. |
Sure, but please explain, what do you need? |
We need someone familiar with valgrind who is willing to work on this issue. |
Hello, I am a golang engineer and interested in performance engineering. I am currently studing how valgrind works and i am willing to conduct a research on this details and give more detailed report about how this can be solved if given the go ahead. Thanks. Looking forward to your response. |
This is probably the place to start. Then we need to understand why valgrind is reporting errors on Go code. Then we need to figure out how to either fix or suppress those errors. |
Oh yes. I am going to start with trying to reproduce the errors as you said. Thanks @randall77 |
Hello @randall77 I started investigating this issue by trying to reproduce the error as you said. I tried running a couple of simple programs that involved cgo. I noticed a consistent result in the valgrind report The number of I just wanted to drop my progress on this as I am still trying to investigate why the |
Running Valgrind with a Go program is very relevant for my use case, where my Go program does multiple cgo calls for alloc/free, and I want to ensure that these calls are correct, i.e. no memory leaks and no double frees. |
@arg0d |
Running
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Probably
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Use valgrind
What did you expect to see?
To pass
What did you see instead?
Errors.
Why is that a problem?
I saw this comment about valgrind:
Valgrind is really a tool for C programs.
It assumes it can replace malloc with its own copy, it assumes
the standard C stack model, I'm sure it assumes other things
specific to that world too.
This is perfectly right.
But I do not run valgrind to check the go application.
I run valgrind to check C/C++ libraries that are linked with my go application!
And as they are libraries, they are linked differently with my go application.
So running valgrind with a different language, would not provide the same result.
Python provide the
PYTHONMALLOC=malloc
.I would except something similar with Go language.
See: https://docs.python.org/3/c-api/memory.html
And: https://docs.python.org/3/using/cmdline.html#envvar-PYTHONMALLOC
The text was updated successfully, but these errors were encountered: