go: valgrind fails

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

$ go version
go version go1.15.15 linux/amd64

Does this issue reproduce with the latest release?

Probably

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

go env Output
$ go env
v
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/erez/.cache/go-build"
GOENV="/home/erez/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/erez/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/erez/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.15"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.15/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-build273804324=/tmp/go-build -gno-record-gcc-switches"

What 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

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

A step-by-step reproducer would definitely help that person.

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.

Ian’s point is that my suggestion won’t help.