Werner Hattingh
unread,Mar 1, 2012, 8:21:43 AM3/1/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Ok so i have found that my one unit test fails intermittently. Every
now and then I get "panic: runtime error: invalid memory address or
nil pointer dereference
" that did not make sense. Traced it to testing.go and add 3 prints:
--- a/src/pkg/testing/testing.go Fri Feb 24 22:42:16 2012 +1100
+++ b/src/pkg/testing/testing.go Thu Mar 01 13:14:21 2012 +0000
@@ -292,6 +292,10 @@
}
func (t *T) report() {
+ fmt.Printf("t %v\n", t )
+ fmt.Printf("t.duration %v\n", t.duration )
+ fmt.Printf("t.duration.Seconds() %v\n", t.duration.Seconds() )
+
tstr := fmt.Sprintf("(%.2f seconds)", t.duration.Seconds())
format := "--- %s: %s %s\n%s"
if t.failed {
OUTPUT at end:
t <nil>
panic: runtime error: invalid memory address or nil pointer
dereference
[signal 0xb code=0x1 addr=0x30 pc=0x422be5]
goroutine 2 [running]:
testing.(*T).report(0x0, 0x63d1c8)
/home/whattingh/go/src/pkg/testing/testing.go:296 +0xf1
testing.RunTests(0x400c00, 0x7d3028, 0x1200000012, 0xf8400d2b01,
0xf8400d7430, ...)
/home/whattingh/go/src/pkg/testing/testing.go:359 +0x80c
testing.Main(0x400c00, 0x7d3028, 0x1200000012, 0x7d5ea0, 0x0, ...)
/home/whattingh/go/src/pkg/testing/testing.go:282 +0x62
main.main()
/tmp/go-build452141823/next/registry/server/_test/_testmain.go:77
+0x91
created by _rt0_amd64
/home/whattingh/go/src/pkg/runtime/asm_amd64.s:69 +0xd1
goroutine 1 [syscall]:
goroutine 3 [syscall]:
created by addtimer
/home/whattingh/go/src/pkg/runtime/ztime_amd64.c:69
goroutine 6 [syscall]:
syscall.Syscall6()
/home/whattingh/go/src/pkg/syscall/asm_linux_amd64.s:40 +0x5
syscall.EpollWait(0xf800000009, 0xf8400ca220, 0xa0000000a, 0xffffffff,
0xc, ...)
/home/whattingh/go/src/pkg/syscall/zerrors_linux_amd64.go:1781 +0xa1
net.(*pollster).WaitFD(0xf8400ca210, 0xf8400db7c0, 0x0, 0x0, 0x0, ...)
/home/whattingh/go/src/pkg/net/fd_linux.go:145 +0x110
net.(*pollServer).Run(0xf8400db7c0, 0x0)
/home/whattingh/go/src/pkg/net/fd.go:236 +0xe4
created by net.newPollServer
/home/whattingh/go/src/pkg/net/newpollserver.go:35 +0x382
exit status 2
FAIL next/registry/server 2.098s
My test func:
func TestRegisterMax(t *testing.T)
I do not use the testing variable in my test function. I do not have
a gobal var "t".
I have know i idea at this moment anymore what to do.
Please help