axw/gocov

segmentation fault when using gocheck with gocov

Closed this issue · 4 comments

I'm receiving the following error:
go build testmain: signal: segmentation fault

I'm using gocheck as a testing framework. This works fine unless I use gocheck in a subpackage.

I don't even know where to start debugging. Any help would be greatly appreciated.

You can see the code here:
https://github.com/imosquera/uploadthis/blob/prehooks/hooks/prehooks_test.go

You can see I'm using gocheck in the main package here:
https://github.com/imosquera/uploadthis/blob/prehooks/conf_test.go

you can also "go get" the package and test it for yourself. Don't forget to check out:
go get -v launchpad.net/gocheck

note: using "go test ./..." all works fine.

axw commented

Isaac, thanks for the detailed issue. I cannot reproduce the issue locally. There was a bug in the Go compiler a while ago that manifested in gocov-instrumented tests. Can you please let me know the output of go version?

FYI, I am running 1.1.1 on the machine I just tested on.

Thanks for responding.

So all I had to do was remove the $GOPATH/pkg dir so that it would recompile the packages. Once I did that it worked fine.

FYI: I'm new to golang, is there a reason why "go clean" and "go build" didn't rebuild the binaries in the pkg dir?

axw commented

So all I had to do was remove the $GOPATH/pkg dir so that it would recompile the packages. Once I did that it worked fine.

Thanks for letting me know. This is a bit concerning though. You shouldn't need to clean the pkg dir. There have been other issues reported that may stem from the same issue. I'll try again later to reproduce this. If you're able to nail down some steps to reproduce this from a clean pkg dir, then that would be very helpful.

FYI: I'm new to golang, is there a reason why "go clean" and "go build" didn't rebuild the binaries in the pkg dir?

go clean -i will clean installed binaries/packages. Plain old go clean is just for removing binary artefacts from the source directory (e.g. a binary left behind from running "go build" in the source dir).

However, you shouldn't need to manually clean the installed packages. The go tool will (should) detect timestamp discrepancies between source and binaries.

axw commented

So, at least, in one scenario...

The "go" command is getting a bit confused with regards to which package
archive to use; the one in the temporary GOROOT, or the one in GOPATH. The
one in GOPATH is being taken if its timestamp is newer than the source
files. I'm not really sure why the go command is getting confused here,
though; the source has been updated in the temporary GOROOT, after all.

I'm going to put in a hack for now, to temporarily remove package files for
instrumented packages, and replace them after running go test. Sucky, but
it works.

On Wed, Sep 25, 2013 at 4:57 AM, Isaac Mosquera notifications@github.comwrote:

Thanks for responding.

So all I had to do was remove the $GOPATH/pkg dir so that it would
recompile the packages. Once I did that it worked fine.

FYI: I'm new to golang, is there a reason why "go clean" and "go build"
didn't rebuild the binaries in the pkg dir?


Reply to this email directly or view it on GitHubhttps://github.com//issues/51#issuecomment-25041865
.

Andrew Wilkins
http://awilkins.id.au