Skip to content

runtime: go test -race on FreeBSD with ASLR reports ok without running any test #65425

@xiaq

Description

@xiaq

Go version

go version go1.21.6 freebsd/amd64

Output of go env in your module/workspace:

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

What did you do?

Ensure ASLR is enabled:

sysctl kern.elf64.aslr.enable=1

Write a test that fails. For reasons I don't understand, this issue only reproduces when the test imports plugin.

// a_test.go
package main_test

import (
        "testing"
        _ "plugin"
)

func TestFail(t *testing.T) {
        t.FailNow()
}

Run the test without -race and it fails, as expected:

# go test
--- FAIL: TestFail (0.00s)
FAIL
exit status 1
FAIL    src.elv.sh/d    0.003s

However, if you run the test with -race, it prints out a warning message and goes on to report the test as if it succeeded:

# go test -race; echo $?
This sanitizer is not compatible with enabled ASLR and binaries compiled with PIE
ok      src.elv.sh/d    0.006s
0

Since the test always fails, it seems that go test -race doesn't actually run the test.

What did you see happen?

go test -race reports "ok" and exits with 0.

What did you expect to see?

go test -race should report failure and exit with 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.RaceDetectorcompiler/runtimeIssues related to the Go compiler and/or runtime.help wanted

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions