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/cover: internal error: overlapping blocks for func literals in switch cases #16540

Closed
stevekuznetsov opened this issue Jul 29, 2016 · 6 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@stevekuznetsov
Copy link

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

    $ go version
    go version go1.6.2 linux/amd64
    
  2. What operating system and processor architecture are you using (go env)?

    $ go env
    GOARCH="amd64"
    GOBIN=""
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GOOS="linux"
    GOPATH="/data"
    GORACE=""
    GOROOT="/usr/lib/golang"
    GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
    GO15VENDOREXPERIMENT="1"
    CC="gcc"
    GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
    CXX="g++"
    CGO_ENABLED="1"
    
  3. What did you do?
    I ran the OpenShift Origin unit tests. Unfortunately this is fairly complicated, but can be achieved with:

    $ git clone git@github.com:openshift/origin.git
    $ cd origin
    $ make build
    $ JUNIT_REPORT=true TEST_KUBE=true hack/test-go.sh
  4. What did you expect to see?
    A successful test run with no errors.

  5. What did you see instead?
    Full output to stdout and stderr

    [WARNING] `go test` had the following output to stderr:
    # cover github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/client/restclient
    cover: internal error: block 264 overlaps block 266
      /data/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/client/restclient/request.go:#27640,#27764 /data/src/github.com/openshift/origin/_output/local/go/src/github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/client/restclient/request.go:#27685,#27704
    

    The file mentioned above can be seen here: request.go.

I'm happy to do more digging but I'm not really sure what the #27640 syntax means or what to look for in the source.

@quentinmit quentinmit changed the title cover: internal error: overlapping blocks cmd/cover: internal error: overlapping blocks Jul 29, 2016
@quentinmit
Copy link
Contributor

@stevekuznetsov I believe the "#27640,#27764" means that the block begins at byte 27640 in the file and ends at byte 27764. So something like "head -c 27764 request.go | tail -c +27640" should print the block it's talking about.

Can you try again with Go 1.7rc3? It's possible that this has already been fixed since 1.6.2. Thanks!

@quentinmit quentinmit added this to the Go1.8 milestone Jul 29, 2016
@quentinmit quentinmit added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 29, 2016
@stevekuznetsov
Copy link
Author

stevekuznetsov commented Jul 29, 2016

I'm afraid I can't install golang-1.7.0-rc3 on our CI super easily so I'm not sure if I can run it on the newer version without also changing other environmental stuff, but I'll give it a shot. Until then:

$ head -c 27764 vendor/k8s.io/kubernetes/pkg/client/restclient/request.go | tail -c +27640 > debug.go
// debug.go
    case bytes.IndexFunc(body, func(r rune) bool { return r < 0x0a }) != -1:
            glog.Infof("Response Body:\n%s", hex.Dump(body))

This corresponds with this snippet of the file.

@stevekuznetsov
Copy link
Author

stevekuznetsov commented Jul 29, 2016

The sub-block identified is:

$ head -c 27704 vendor/k8s.io/kubernetes/pkg/client/restclient/request.go | tail -c +27685 > debug.go
// debug.go 
 { return r < 0x0a }

@fjl
Copy link

fjl commented Jul 29, 2016

We have a similar issue in github.com/ethereum/go-ethereum/p2p. The statement that causes it also involves a function literal inside case.

# cover github.com/ethereum/go-ethereum/p2p
cover: internal error: block 17 overlaps block 19
    /Users/travis/gopath/src/github.com/ethereum/go-ethereum/p2p/server.go:#6707,#6842 /Users/travis/gopath/src/github.com/ethereum/go-ethereum/p2p/server.go:#6764,#6792
cover: internal error: block 23 overlaps block 25
    /Users/travis/gopath/src/github.com/ethereum/go-ethereum/p2p/server.go:#6993,#7086 /Users/travis/gopath/src/github.com/ethereum/go-ethereum/p2p/server.go:#7047,#7066

It still happens with go 1.7rc3.

@minux
Copy link
Member

minux commented Jul 30, 2016

A smaller and standalone reproduction:

$ cat issue16540_test.go
package issue16540
import "testing"
func Test(t *testing.T) {
switch {
case 1 == func() int { return 1 }():
return
}
}
$ go tool cover -mode=set -var=XXXX issue16540_test.go > /dev/null
cover: internal error: block 1 overlaps block 2
issue16540_test.go:#73,#118 issue16540_test.go:#94,#106

The two overlapping ranges are:
case 1 == func() int { return 1 }(): return
And:
{ return 1 }

@gopherbot
Copy link

CL https://golang.org/cl/32612 mentions this issue.

@golang golang locked and limited conversation to collaborators Nov 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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

5 participants