Skip to content

cmd/go: unexpected panic when running go test on particular package without test files #25789

Closed
@mark-rushakoff

Description

@mark-rushakoff

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

gotip version
go version devel +7b08e619bb Thu Jun 7 16:17:04 2018 +0000 darwin/amd64

Does this issue reproduce with the latest release?

I tested with go1.10.1 and it does not reproduce.

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

$ gotip env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mr/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mr/go"
GORACE=""
GOROOT="/Users/mr/gotip/src/github.com/golang/go"
GOTMPDIR=""
GOTOOLDIR="/Users/mr/gotip/src/github.com/golang/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ct/bl4_z3g51ks8239_r2k07v_40000gn/T/go-build990290390=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I created a repository that you can clone to reproduce this issue: https://github.com/mark-rushakoff/testpanic

I am sure the repro case could be stripped down quite a bit, but I do not have time to minimize it any further right now.

That repository's main.go contains only the following code:

package main

import (
	"net/http"

	"github.com/elazarl/goproxy"
	"github.com/sirupsen/logrus"
)

func main() {
	proxy := goproxy.NewProxyHttpServer()
	proxy.Verbose = true
	logrus.Fatal(http.ListenAndServe(":8080", proxy))
}

Then I ran go test .

What did you expect to see?

I expected to see the same output that I see in go 1.10:

go test .
?       github.com/mark-rushakoff/testpanic     [no test files]

What did you see instead?

I saw a panic from an init function, that I would not have expected to run on account of there being no test files:

$ GOTRACEBACK=system gotip test .
panic: Error parsing builtin CA x509: RSA key missing NULL parameters

goroutine 1 [running]:
panic(0x1271080, 0xc000049060)
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/panic.go:537 +0x2cb fp=0xc000115df0 sp=0xc000115d60 pc=0x102cbfb
github.com/mark-rushakoff/testpanic/vendor/github.com/elazarl/goproxy.init.0()
        /Users/mr/go/src/github.com/mark-rushakoff/testpanic/vendor/github.com/elazarl/goproxy/certs.go:10 +0x1bc fp=0xc000115e58 sp=0xc000115df0 pc=0x1240b0c
github.com/mark-rushakoff/testpanic/vendor/github.com/elazarl/goproxy.init()
        <autogenerated>:1 +0x250 fp=0xc000115f78 sp=0xc000115e58 pc=0x1240d70
github.com/mark-rushakoff/testpanic.init()
        <autogenerated>:1 +0x4a fp=0xc000115f88 sp=0xc000115f78 pc=0x1243faa
main.init()
        <autogenerated>:1 +0x54 fp=0xc000115f98 sp=0xc000115f88 pc=0x1244254
runtime.main()
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/proc.go:189 +0x1bd fp=0xc000115fe0 sp=0xc000115f98 pc=0x102e8ad
runtime.goexit()
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc000115fe8 sp=0xc000115fe0 pc=0x105b941

goroutine 2 [force gc (idle)]:
runtime.gopark(0x12eb408, 0x14ea090, 0x1410, 0x1)
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/proc.go:298 +0xeb fp=0xc000032f80 sp=0xc000032f60 pc=0x102eceb
runtime.goparkunlock(0x14ea090, 0x1410, 0x1)
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/proc.go:304 +0x53 fp=0xc000032fb0 sp=0xc000032f80 pc=0x102ed93
runtime.forcegchelper()
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/proc.go:251 +0xb3 fp=0xc000032fe0 sp=0xc000032fb0 pc=0x102eb63
runtime.goexit()
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc000032fe8 sp=0xc000032fe0 pc=0x105b941
created by runtime.init.4
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/proc.go:240 +0x35

goroutine 3 [GC sweep wait]:
runtime.gopark(0x12eb408, 0x14ea1e0, 0x102140c, 0x1)
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/proc.go:298 +0xeb fp=0xc000033780 sp=0xc000033760 pc=0x102eceb
runtime.goparkunlock(0x14ea1e0, 0x131140c, 0x1)
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/proc.go:304 +0x53 fp=0xc0000337b0 sp=0xc000033780 pc=0x102ed93
runtime.bgsweep(0xc00006a000)
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/mgcsweep.go:52 +0x8f fp=0xc0000337d8 sp=0xc0000337b0 pc=0x1020b5f
runtime.goexit()
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc0000337e0 sp=0xc0000337d8 pc=0x105b941
created by runtime.gcenable
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/mgc.go:216 +0x58

goroutine 4 [finalizer wait]:
runtime.gopark(0x12eb408, 0x1507da0, 0x129140f, 0x1)
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/proc.go:298 +0xeb fp=0xc000032728 sp=0xc000032708 pc=0x102eceb
runtime.goparkunlock(0x1507da0, 0x140f, 0x1)
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/proc.go:304 +0x53 fp=0xc000032758 sp=0xc000032728 pc=0x102ed93
runtime.runfinq()
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/mfinal.go:175 +0x99 fp=0xc0000327e0 sp=0xc000032758 pc=0x10185b9
runtime.goexit()
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc0000327e8 sp=0xc0000327e0 pc=0x105b941
created by runtime.createfing
        /Users/mr/gotip/src/github.com/golang/go/src/runtime/mfinal.go:156 +0x61
FAIL    github.com/mark-rushakoff/testpanic     0.017s

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions