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

Test report unexpected error when race detection is enabled #50323

Closed
ysmood opened this issue Dec 23, 2021 · 1 comment
Closed

Test report unexpected error when race detection is enabled #50323

ysmood opened this issue Dec 23, 2021 · 1 comment

Comments

@ysmood
Copy link

ysmood commented Dec 23, 2021

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

$ go version
go version go1.17.5 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ys/Library/Caches/go-build"
GOENV="/Users/ys/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/ys/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/ys/go"
GOPRIVATE=""
GOPROXY=""
GOROOT="/Users/ys/go1.7.5"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/ys/go1.7.5/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/ys/repos/play/default/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2f/vgdz042d7pn35jczyk5pbdbw0000gn/T/go-build103773740=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Clean the cache by go clean.
Create an empty go module with go mod init play, create a file main_test.go:

package main_test

import "os/exec"

func init() {
	exec.Command("echo").Run()
}

Run go test -race

What did you expect to see?

Test passes without error info.

What did you see instead?

Test reports unexpected error:

Output
play.test(2013,0xa6fb600) malloc: *** error for object 0x600001700080: pointer being freed was not allocated
play.test(2013,0xa6fb600) malloc: *** set a breakpoint in malloc_error_break to debug
SIGABRT: abort
PC=0x7ff816761112 m=0 sigcode=0

goroutine 0 [idle]:
syscall.rawSyscall(0x10b79c0, 0x0, 0x0, 0x0)
/Users/ys/go1.7.5/src/runtime/sys_darwin.go:77 +0x47 fp=0xc000131660 sp=0xc000131640 pc=0x10a5707
syscall.rawSyscall(0x10ab5c5, 0x0, 0x0, 0x1)
:1 +0x26 fp=0xc0001316a8 sp=0xc000131660 pc=0x10abce6
syscall.forkAndExecInChild(0xc0001260a6, {0xc00011a3f0, 0x2, 0xd0}, {0xc00015c000, 0x1b, 0x9a63a00}, 0x0, 0x0, 0xc0001319b0, ...)
/Users/ys/go1.7.5/src/syscall/exec_libc2.go:80 +0xed fp=0xc000131738 sp=0xc0001316a8 pc=0x10b38cd
syscall.forkExec({0xc000126057, 0x9}, {0xc00011a3d0, 0x1, 0x1}, 0xc0001319b0)
/Users/ys/go1.7.5/src/syscall/exec_unix.go:210 +0x58f fp=0xc0001318d0 sp=0xc000131738 pc=0x10b494f
syscall.StartProcess(...)
/Users/ys/go1.7.5/src/syscall/exec_unix.go:256
os.startProcess({0xc000126057, 0x9}, {0xc00011a3d0, 0x1, 0x1}, 0xc000131c40)
/Users/ys/go1.7.5/src/os/exec_posix.go:55 +0x526 fp=0xc000131a08 sp=0xc0001318d0 pc=0x10d1fa6
os.StartProcess({0xc000126057, 0x9}, {0xc00011a3d0, 0x1, 0x1}, 0x24b40)
/Users/ys/go1.7.5/src/os/exec.go:109 +0x7a fp=0xc000131a68 sp=0xc000131a08 pc=0x10d197a
os/exec.(*Cmd).Start(0xc000152000)
/Users/ys/go1.7.5/src/os/exec/exec.go:422 +0x9d4 fp=0xc000131c98 sp=0xc000131a68 pc=0x1185214
os/exec.(*Cmd).Run(0x11b8212)
/Users/ys/go1.7.5/src/os/exec/exec.go:338 +0x31 fp=0xc000131cd8 sp=0xc000131c98 pc=0x11847d1
play_test.init.0()
/Users/ys/repos/play/default/main_test.go:6 +0x3b fp=0xc000131d10 sp=0xc000131cd8 pc=0x118701b
runtime.doInit(0x12b1d60)
/Users/ys/go1.7.5/src/runtime/proc.go:6498 +0x123 fp=0xc000131e48 sp=0xc000131d10 pc=0x1084d03
runtime.doInit(0x12b2820)
/Users/ys/go1.7.5/src/runtime/proc.go:6475 +0x71 fp=0xc000131f80 sp=0xc000131e48 pc=0x1084c51
runtime.main()
/Users/ys/go1.7.5/src/runtime/proc.go:238 +0x1e6 fp=0xc000131fe0 sp=0xc000131f80 pc=0x1077706
runtime.goexit()
/Users/ys/go1.7.5/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000131fe8 sp=0xc000131fe0 pc=0x10a8ae1

goroutine 1 [running, locked to thread]:
runtime.systemstack_switch()
/Users/ys/go1.7.5/src/runtime/asm_amd64.s:350 fp=0xc000131610 sp=0xc000131608 pc=0x10a68a0
runtime.libcCall(0x18, 0x12d46a0)
/Users/ys/go1.7.5/src/runtime/sys_libc.go:49 +0x66 fp=0xc000131640 sp=0xc000131610 pc=0x1096186
syscall.rawSyscall(0x10b79c0, 0x0, 0x0, 0x0)
/Users/ys/go1.7.5/src/runtime/sys_darwin.go:77 +0x47 fp=0xc000131660 sp=0xc000131640 pc=0x10a5707
syscall.rawSyscall(0x10ab5c5, 0x0, 0x0, 0x1)
:1 +0x26 fp=0xc0001316a8 sp=0xc000131660 pc=0x10abce6
syscall.forkAndExecInChild(0xc0001260a6, {0xc00011a3f0, 0x2, 0xd0}, {0xc00015c000, 0x1b, 0x9a63a00}, 0x0, 0x0, 0xc0001319b0, ...)
/Users/ys/go1.7.5/src/syscall/exec_libc2.go:80 +0xed fp=0xc000131738 sp=0xc0001316a8 pc=0x10b38cd
syscall.forkExec({0xc000126057, 0x9}, {0xc00011a3d0, 0x1, 0x1}, 0xc0001319b0)
/Users/ys/go1.7.5/src/syscall/exec_unix.go:210 +0x58f fp=0xc0001318d0 sp=0xc000131738 pc=0x10b494f
syscall.StartProcess(...)
/Users/ys/go1.7.5/src/syscall/exec_unix.go:256
os.startProcess({0xc000126057, 0x9}, {0xc00011a3d0, 0x1, 0x1}, 0xc000131c40)
/Users/ys/go1.7.5/src/os/exec_posix.go:55 +0x526 fp=0xc000131a08 sp=0xc0001318d0 pc=0x10d1fa6
os.StartProcess({0xc000126057, 0x9}, {0xc00011a3d0, 0x1, 0x1}, 0x24b40)
/Users/ys/go1.7.5/src/os/exec.go:109 +0x7a fp=0xc000131a68 sp=0xc000131a08 pc=0x10d197a
os/exec.(*Cmd).Start(0xc000152000)
/Users/ys/go1.7.5/src/os/exec/exec.go:422 +0x9d4 fp=0xc000131c98 sp=0xc000131a68 pc=0x1185214
os/exec.(*Cmd).Run(0x11b8212)
/Users/ys/go1.7.5/src/os/exec/exec.go:338 +0x31 fp=0xc000131cd8 sp=0xc000131c98 pc=0x11847d1
play_test.init.0()
/Users/ys/repos/play/default/main_test.go:6 +0x3b fp=0xc000131d10 sp=0xc000131cd8 pc=0x118701b
runtime.doInit(0x12b1d60)
/Users/ys/go1.7.5/src/runtime/proc.go:6498 +0x123 fp=0xc000131e48 sp=0xc000131d10 pc=0x1084d03
runtime.doInit(0x12b2820)
/Users/ys/go1.7.5/src/runtime/proc.go:6475 +0x71 fp=0xc000131f80 sp=0xc000131e48 pc=0x1084c51
runtime.main()
/Users/ys/go1.7.5/src/runtime/proc.go:238 +0x1e6 fp=0xc000131fe0 sp=0xc000131f80 pc=0x1077706
runtime.goexit()
/Users/ys/go1.7.5/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000131fe8 sp=0xc000131fe0 pc=0x10a8ae1

rax 0x0
rbx 0xa6fb600
rcx 0x7ff7bfeff618
rdx 0x0
rdi 0x303
rsi 0x6
rbp 0x7ff7bfeff640
rsp 0x7ff7bfeff618
r8 0x0
r9 0x0
r10 0x0
r11 0x246
r12 0x303
r13 0x50
r14 0x6
r15 0x16
rip 0x7ff816761112
rflags 0x246
cs 0x7
fs 0x0
gs 0x0
testing: warning: no tests to run
PASS
ok play 0.439s

Notes

  • This happened after I upgraded the macOS to 12.1 (21C52), not sure if they are related.

  • The code works for Linux.

  • Run without -race works fine.

@ysmood ysmood changed the title Test crash on race detection enabled Test crashes when race detection enabled Dec 23, 2021
@ysmood ysmood changed the title Test crashes when race detection enabled Test crashes when race detection is enabled Dec 23, 2021
@ysmood ysmood changed the title Test crashes when race detection is enabled Test report unexpected error when race detection is enabled Dec 23, 2021
@ysmood
Copy link
Author

ysmood commented Dec 23, 2021

After reading the #49138

The MallocNanoZone=0 go test -race works for me.

@ysmood ysmood closed this as completed Dec 23, 2021
@golang golang locked and limited conversation to collaborators Dec 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants