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/go: test -coverprofile option causes test to panic #41442

Open
daixiang0 opened this issue Sep 17, 2020 · 1 comment
Open

cmd/go: test -coverprofile option causes test to panic #41442

daixiang0 opened this issue Sep 17, 2020 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@daixiang0
Copy link

daixiang0 commented Sep 17, 2020

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

$ go version
go version go1.14.4 linux/amd64

Also test with 1.14.9 and 1.15.2, all fail.

Does this issue reproduce with the latest release?

Yep.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
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=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/go/src/github.com/kubeedge/kubedge/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build657190380=/tmp/go-build -gno-record-gcc-switches"

What did you do?

To get coverfile, i add option for go test, then go test failed:

root@70bbf38bedaf:/go/src/github.com/kubeedge/kubedge# git show
commit 791d503c74b9cdfe2c43a54ad3286fe12ff10d1e (HEAD -> master, origin/master, origin/HEAD)
Author: Xiang Dai <long0dai@foxmail.com>
Date:   Fri Sep 11 16:07:09 2020 +0800

    Generate coverprofile when test

    Signed-off-by: Xiang Dai <long0dai@foxmail.com>

diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh
index 14d530a9..d8bcc57d 100644
--- a/hack/lib/golang.sh
+++ b/hack/lib/golang.sh
@@ -434,5 +434,5 @@ kubeedge::golang::run_test() {
     testdirs+=("${KUBEEDGE_ALL_TESTCASES[@]}")
   fi

-  go test ${testdirs[@]}
+  go test -coverprofile=coverprofile.cov ${testdirs[@]}
 }
root@70bbf38bedaf:/go/src/github.com/kubeedge/kubedge# make test
hack/make-rules/clean.sh
hack/make-rules/test.sh
running tests cases
ok  	github.com/kubeedge/kubeedge/cloud/pkg/cloudhub/common/model	0.009s	coverage: 96.3% of statements
ok  	github.com/kubeedge/kubeedge/cloud/pkg/edgecontroller/manager	0.027s	coverage: 26.4% of statements
ok  	github.com/kubeedge/kubeedge/edge/pkg/devicetwin	0.019s	coverage: 82.2% of statements
ok  	github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dttype	0.027s	coverage: 95.4% of statements
ok  	github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtmodule	0.019s	coverage: 55.6% of statements
ok  	github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtclient	0.028s	coverage: 96.1% of statements
ok  	github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtcontext	0.013s	coverage: 93.8% of statements
ok  	github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtmanager	51.048s	coverage: 85.6% of statements
ok  	github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtcommon	0.014s	coverage: 100.0% of statements
ok  	github.com/kubeedge/kubeedge/edge/pkg/metamanager/dao	0.011s	coverage: 100.0% of statements
PASS
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0xb75749]

goroutine 12 [running]:
github.com/kubeedge/kubeedge/edge/pkg/metamanager/dao.QueryAllMeta(0xd6e86a, 0x4, 0xd70d24, 0x9, 0x0, 0x0, 0x0)
	/go/src/github.com/kubeedge/kubedge/edge/pkg/metamanager/dao/meta.go:97 +0x49
github.com/kubeedge/kubeedge/edge/pkg/metamanager.(*metaManager).syncPodStatus(0xc00003d418)
	/go/src/github.com/kubeedge/kubedge/edge/pkg/metamanager/process.go:516 +0xa9
github.com/kubeedge/kubeedge/edge/pkg/metamanager.(*metaManager).processSync(...)
	/go/src/github.com/kubeedge/kubedge/edge/pkg/metamanager/process.go:511
github.com/kubeedge/kubeedge/edge/pkg/metamanager.(*metaManager).process(0xc00003d418, 0xc000040e40, 0x24, 0x0, 0x0, 0x17499ee0ec9, 0x0, 0x0, 0x0, 0xd722e4, ...)
	/go/src/github.com/kubeedge/kubedge/edge/pkg/metamanager/process.go:646 +0x50b
github.com/kubeedge/kubeedge/edge/pkg/metamanager.(*metaManager).runMetaManager.func1(0xc00003d418)
	/go/src/github.com/kubeedge/kubedge/edge/pkg/metamanager/process.go:670 +0x318
created by github.com/kubeedge/kubeedge/edge/pkg/metamanager.(*metaManager).runMetaManager
	/go/src/github.com/kubeedge/kubedge/edge/pkg/metamanager/process.go:660 +0x49
FAIL	github.com/kubeedge/kubeedge/edge/pkg/metamanager	0.009s
ok  	github.com/kubeedge/kubeedge/edge/pkg/servicebus/util	0.021s	coverage: 60.6% of statements
ok  	github.com/kubeedge/kubeedge/edge/pkg/eventbus/common/util	0.019s	coverage: 65.9% of statements
ok  	github.com/kubeedge/kubeedge/edge/pkg/edgehub/clients/wsclient	0.190s	coverage: 3.0% of statements
ok  	github.com/kubeedge/kubeedge/edge/pkg/edgehub/common/http	0.071s	coverage: 36.7% of statements
ok  	github.com/kubeedge/kubeedge/edge/pkg/edgehub	24.017s	coverage: 60.6% of statements
ok  	github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd/util	0.010s	coverage: 1.1% of statements
FAIL
make: *** [Makefile:91: test] Error 1

Reproduce:

$ docker run -it golang:1.14 bash
$ go get github.com/daixiang0/kubeedge
$ cd /go/src/github.com/daixiang0/kubeedge
$ make test

What did you expect to see?

Test pass.

What did you see instead?

Test failed.

If revert this change, test pass.

I check docs while do not get any helpful info :(

@daixiang0
Copy link
Author

@bcmills hi, mind have a look?

@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 21, 2020
@toothrot toothrot added this to the Backlog milestone Sep 21, 2020
@toothrot toothrot changed the title cmd/cover: add coverprofile option make test failed cmd/go: test -coverprofile option causes test to panic Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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