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

cmd/cgo/internal/testsanitizers: TestLibFuzzer and TestMSAN fail with CC=clang CGO_ENABLED=0 #64626

Closed
ttttcrngyblflpp opened this issue Dec 8, 2023 · 6 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ttttcrngyblflpp
Copy link

Go version

go version go1.21.4 linux/amd64

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

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/usr/local/google/home/gongt/.cache/go-build'
GOENV='/usr/local/google/home/gongt/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/usr/local/google/home/gongt/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/usr/local/google/home/gongt/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/google/home/gongt/goc'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/google/home/gongt/goc/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/usr/local/google/home/gongt/goc/src/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 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2742143614=/tmp/go-build -gno-record-gcc-switches'

What did you do?

On a clean checkout of go1.21.4, run:

cd src
CC=clang CGO_ENABLED=0 ./make.bash
./run.bash

My clang version is 14.0.6.

What did you expect to see?

All tests pass.

What did you see instead?

--- FAIL: TestLibFuzzer (0.33s)
    --- FAIL: TestLibFuzzer/libfuzzer1 (0.01s)
        libfuzzer_test.go:49: /usr/local/google/home/gongt/goc/bin/go build -tags=libfuzzer -gcflags=-d=libfuzzer -buildmode=c-archive -o /tmp/TestLibFuzzer3296197254/libfuzzer1.a testdata/libfuzzer1.go exited with exit status 1
            go: no Go source files
    --- FAIL: TestLibFuzzer/libfuzzer2 (0.01s)
        libfuzzer_test.go:49: /usr/local/google/home/gongt/goc/bin/go build -tags=libfuzzer -gcflags=-d=libfuzzer -buildmode=c-archive -o /tmp/TestLibFuzzer850547297/libfuzzer2.a testdata/libfuzzer2.go exited with exit status 1
            go: no Go source files
--- FAIL: TestMSAN (0.27s)
    msan_test.go:38: /usr/local/google/home/gongt/goc/bin/go build -msan std exited with exit status 2
        go: -msan requires cgo; enable cgo by setting CGO_ENABLED=1
FAIL
FAIL	cmd/cgo/internal/testsanitizers	0.648s
@ttttcrngyblflpp
Copy link
Author

Oh, forgot to mention that these tests pass if CC=gcc for whatever reason.

@mauri870
Copy link
Member

mauri870 commented Dec 9, 2023

It can be that CC=gcc trigger some code path that disable msan and fuzzer, given that -fsanitize=memory and -fsanitize=fuzzerare not supported by gcc, only clang.

@mauri870
Copy link
Member

mauri870 commented Dec 9, 2023

So I think this is expected. If CC=clang it runs msan tests, which require CGO_ENABLED=1, so the error you get seems correct.

@mauri870 mauri870 added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. compiler/runtime Issues related to the Go compiler and/or runtime. labels Dec 9, 2023
@mauri870
Copy link
Member

mauri870 commented Dec 9, 2023

Well, now thinking more about it, if the user explicitly sets CGO_ENABLED=0, it indicates a preference to avoid running any tests that depend on cgo. Perhaps we should also consider skipping msan and fuzzer tests, given that we already skip race and asan tests under this condition.

cc @golang/runtime

@mauri870 mauri870 added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Dec 11, 2023
@mauri870 mauri870 self-assigned this Dec 11, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/548715 mentions this issue: cmd/cgo/internal/testsanitizers: check for go build and cgo in fuzzer and msan tests

@cherrymui
Copy link
Member

All cmd/cgo/internal/ tests probably should be skipped if cgo is not enabled.

ezz-no pushed a commit to ezz-no/go-ezzno that referenced this issue Feb 18, 2024
… and msan tests

Make sure the platform we are running the tests on can compile programs
and has cgo support in order to run the fuzzer and msan tests. This is the
same approach used by the asan tests, which share the same requirements.

Fixes golang#64626

Change-Id: I7c0b912dabdd1b7d7d44437e4ade5e5994994796
GitHub-Last-Rev: 9fae697
GitHub-Pull-Request: golang#64640
Reviewed-on: https://go-review.googlesource.com/c/go/+/548715
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Bryan Mills <[email protected]>
Reviewed-by: Matthew Dempsky <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
@dmitshur dmitshur added this to the Go1.22 milestone Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants