davecgh / go-spew

Implements a deep pretty printer for Go data structures to aid in debugging
ISC License
5.97k stars 361 forks source link

tests fail with gotip #15

Closed mpl closed 10 years ago

mpl commented 10 years ago

something in gotip must have changed recently and is making the tests fail. They pass fine with: go version devel +7e1a4e190b02 Thu Dec 19 13:02:06 2013 +0900 linux/amd64 but with: go version devel +c344ec9f4318 Wed Jan 01 00:00:22 2014 +1100 linux/amd64

=== RUN TestInvalidReflectValue --- PASS: TestInvalidReflectValue (0.00 seconds) === RUN TestAddedReflectValue --- FAIL: TestAddedReflectValue (0.00 seconds) internal_test.go:120: TestAddedReflectValue #1 got: (int8) -12 want: (int8) 5 internal_test.go:131: TestAddedReflectValue #2 got: (int8) -11 want: (int8) internal_test.go:143: TestAddedReflectValue #3 got: -12 want: 5 internal_test.go:155: TestAddedReflectValue #4 got: -11 want: === RUN TestSortValues --- PASS: TestSortValues (0.00 seconds) === RUN TestDump --- FAIL: TestDump (0.00 seconds) dump_test.go:888: Running 193 tests panic: reflect.Value.Addr of unaddressable value [recovered] panic: reflect.Value.Addr of unaddressable value

goroutine 6 [running]: runtime.panic(0x56a120, 0xc210063c30) /home/mpl/gotip/src/pkg/runtime/panic.c:264 +0xb6 testing.func·005() /home/mpl/gotip/src/pkg/testing/testing.go:385 +0xe8 runtime.panic(0x56a120, 0xc210063c30) /home/mpl/gotip/src/pkg/runtime/panic.c:246 +0x106 reflect.Value.Addr(0x0, 0x0, 0x0, 0x0, 0x0, ...) /home/mpl/gotip/src/pkg/reflect/value.go:385 +0x75 github.com/davecgh/go-spew/spew.handleMethods(0x7f5a00, 0x7f4e29a8d308, 0xc2100702a0, 0x0, 0x0, ...) /home/mpl/gocode/src/github.com/davecgh/go-spew/spew/common.go:142 +0x146 github.com/davecgh/go-spew/spew.(*dumpState).dump(0xc210072270, 0x569e20, 0x0, 0x7f, 0x30) /home/mpl/gocode/src/github.com/davecgh/go-spew/spew/dump.go:277 +0x348 github.com/davecgh/go-spew/spew.fdump(0x7f5a00, 0x7f4e29a8d308, 0xc2100702a0, 0x7f4e29903e88, 0x1, ...) /home/mpl/gocode/src/github.com/davecgh/go-spew/spew/dump.go:430 +0x287 github.com/davecgh/go-spew/spew.Fdump(0x7f4e29a8d308, 0xc2100702a0, 0x7f4e29903e88, 0x1, 0x1) /home/mpl/gocode/src/github.com/davecgh/go-spew/spew/dump.go:438 +0x5c github.com/davecgh/go-spew/spew_test.TestDump(0xc210058240) /home/mpl/gocode/src/github.com/davecgh/go-spew/spew/dump_test.go:891 +0x2c0 testing.tRunner(0xc210058240, 0x7f90c8) /home/mpl/gotip/src/pkg/testing/testing.go:391 +0x8b created by testing.RunTests /home/mpl/gotip/src/pkg/testing/testing.go:471 +0x958

goroutine 1 [chan receive]: testing.RunTests(0x60d450, 0x7f9080, 0x8, 0x8, 0x0) /home/mpl/gotip/src/pkg/testing/testing.go:472 +0x97b testing.Main(0x60d450, 0x7f9080, 0x8, 0x8, 0x7fd940, ...) /home/mpl/gotip/src/pkg/testing/testing.go:403 +0x8c main.main() /tmp/go-build429184412/github.com/davecgh/go-spew/spew/_test/_testmain.go:73 +0x9c exit status 2 FAIL github.com/davecgh/go-spew/spew 0.005s

dominikh commented 10 years ago

It's caused by the following commit

changeset:   18686:ecccf07e7f9d
user:        Keith Randall <khr@golang.org>
date:        Thu Dec 19 15:15:24 2013 -0800
summary:     reflect: rewrite Value to separate out pointer vs. nonpointer info.

Initially I thought it was a regression in Go, but unsafeReflectValue in go-spew makes me think it's a bug in go-spew and the way it uses unsafe.

dominikh commented 10 years ago

Also, to demonstrate the effect of the issue: http://play.golang.org/p/6hvHaXh0b8 – It fails for a specific pattern of values.

davecgh commented 10 years ago

I just saw this amongst all of the other traffic. After quickly looking at this, I imagine the structure of the internal reflect package structure that spew is mirroring has changed. This is required to provide a lot of its functionality against unexported fields.