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

internal/fuzz: odr-violation error #66966

Open
n-bes opened this issue Apr 22, 2024 · 1 comment
Open

internal/fuzz: odr-violation error #66966

n-bes opened this issue Apr 22, 2024 · 1 comment
Labels
arch-amd64 NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@n-bes
Copy link

n-bes commented Apr 22, 2024

Go version

go1.22.2 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/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-build3964025102=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I ran this code on MacBook M3-chip with Docker Desktop and used latest official docker images (debian / alpine).

func FuzzParser(f *testing.F) {
	f.Fuzz(func(t *testing.T, data string) {
	})
}

What did you see happen?

# go test -fuzz=Fuzz -asan .

==40621==The following global variable is not properly aligned.
==40621==This may happen if another global with the same name
==40621==resides in another non-instrumented module.
==40621==Or the global comes from a C file built w/o -fno-common.
==40621==In either case this is likely an ODR violation bug,
==40621==but AddressSanitizer can not provide more details.
=================================================================
==40621==ERROR: AddressSanitizer: odr-violation (0x000005fecce3):
  [1] size=0 'internal/fuzz._ecounters' /usr/local/go/src/internal/fuzz/coverage.go:106:13
  [2] size=0 'internal/fuzz._ecounters' /usr/local/go/src/internal/fuzz/coverage.go:106:13
These globals were registered at these points:
  [1]:
    #0 0x2aaaab3211b8 in __asan_register_globals ../../../../src/libsanitizer/asan/asan_globals.cpp:341
    #1 0x183858c  (/tmp/go-build3032263961/b001/scan.test+0x183858c)

  [2]:
    #0 0x2aaaab3211b8 in __asan_register_globals ../../../../src/libsanitizer/asan/asan_globals.cpp:341
    #1 0x183858c  (/tmp/go-build3032263961/b001/scan.test+0x183858c)

==40621==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY: AddressSanitizer: odr-violation: global 'internal/fuzz._ecounters' at /usr/local/go/src/internal/fuzz/coverage.go:106:13
==40621==ABORTING
# go test -asan -fuzz=Fuzz .

==20374==The following global variable is not properly aligned.
==20374==This may happen if another global with the same name
==20374==resides in another non-instrumented module.
==20374==Or the global comes from a C file built w/o -fno-common.
==20374==In either case this is likely an ODR violation bug,
==20374==but AddressSanitizer can not provide more details.
=================================================================
==20374==ERROR: AddressSanitizer: odr-violation (0x000006b0c2c3):
  [1] size=0 'internal/fuzz._ecounters' /usr/local/go/src/internal/fuzz/coverage.go:106:13
  [2] size=0 'internal/fuzz._ecounters' /usr/local/go/src/internal/fuzz/coverage.go:106:13
These globals were registered at these points:
  [1]:
    #0 0x17ef29b  (/tmp/go-build585142908/b001/scan.test+0x17ef29b) (BuildId: 367c8411fdfbdc6ab6efe02464d6626ff04f1a3c)
    #1 0x191956c  (/tmp/go-build585142908/b001/scan.test+0x191956c) (BuildId: 367c8411fdfbdc6ab6efe02464d6626ff04f1a3c)

  [2]:
    #0 0x17ef29b  (/tmp/go-build585142908/b001/scan.test+0x17ef29b) (BuildId: 367c8411fdfbdc6ab6efe02464d6626ff04f1a3c)
    #1 0x191956c  (/tmp/go-build585142908/b001/scan.test+0x191956c) (BuildId: 367c8411fdfbdc6ab6efe02464d6626ff04f1a3c)

==20374==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY: AddressSanitizer: odr-violation: global 'internal/fuzz._ecounters' at /usr/local/go/src/internal/fuzz/coverage.go:106:13
==20374==ABORTING
exit status 1

What did you expect to see?

I've tried to set ASAN_OPTIONS=detect_odr_violation=0 without success:

  • before build
  • after build
  • testing.F.Setenv
@mauri870 mauri870 added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. arch-arm64 arch-amd64 and removed arch-arm64 labels Apr 22, 2024
@n-bes
Copy link
Author

n-bes commented Apr 23, 2024

MRE:
go.mod:

module hello

go 1.22.2

main_test.go:

package hello

import (
	"testing"
	"unicode/utf8"
)

func Reverse(s string) string {
	b := []byte(s)
	for i, j := 0, len(b)-1; i < len(b)/2; i, j = i+1, j-1 {
		b[i], b[j] = b[j], b[i]
	}
	return string(b)
}

func FuzzReverse(f *testing.F) {
	testcases := []string{"Hello, world", " ", "!12345"}
	for _, tc := range testcases {
		f.Add(tc) // Use f.Add to provide a seed corpus
	}
	f.Fuzz(func(t *testing.T, orig string) {
		rev := Reverse(orig)
		doubleRev := Reverse(rev)
		if orig != doubleRev {
			t.Errorf("Before: %q, after: %q", orig, doubleRev)
		}
		if utf8.ValidString(orig) && !utf8.ValidString(rev) {
			t.Errorf("Reverse produced invalid UTF-8 string %q", rev)
		}
	})
}
docker run --rm -it -v $PWD:/src golang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-amd64 NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants