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

stevekuznetsov opened this issue Jul 29, 2016 · 6 comments


Copy link

@stevekuznetsov stevekuznetsov commented Jul 29, 2016

  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
    GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
  3. What did you do?
    I ran the OpenShift Origin unit tests. Unfortunately this is fairly complicated, but can be achieved with:

    $ git clone
    $ cd origin
    $ make build
    $ JUNIT_REPORT=true TEST_KUBE=true hack/
  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
    cover: internal error: block 264 overlaps block 266
      /data/src/,#27764 /data/src/,#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
Copy link

@quentinmit quentinmit commented Jul 29, 2016

@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
Copy link

@stevekuznetsov 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/ | 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.

Copy link

@stevekuznetsov stevekuznetsov commented Jul 29, 2016

The sub-block identified is:

$ head -c 27704 vendor/ | tail -c +27685 > debug.go
// debug.go 
 { return r < 0x0a }
Copy link

@fjl fjl commented Jul 29, 2016

We have a similar issue in The statement that causes it also involves a function literal inside case.

# cover
cover: internal error: block 17 overlaps block 19
    /Users/travis/gopath/src/,#6842 /Users/travis/gopath/src/,#6792
cover: internal error: block 23 overlaps block 25
    /Users/travis/gopath/src/,#7086 /Users/travis/gopath/src/,#7066

It still happens with go 1.7rc3.

Copy link

@minux 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 }():
$ 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
{ return 1 }

Copy link

@gopherbot gopherbot commented Nov 3, 2016

CL mentions this issue.

@gopherbot gopherbot closed this in a4a4d43 Nov 3, 2016
@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.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.