RobotsAndPencils/buford

panic error

Closed this issue · 12 comments

panic: close of closed channel

goroutine 46 [running]:
panic(0x7c8aa0, 0xc8206dc8c0)
/home/users/tianwanli01/Code/Go/go-go1.6/src/runtime/panic.go:464 +0x3e6
golang.org/x/net/http2.(_ClientConn).streamByID(0xc820082b00, 0x100000001, 0x0)
/home/users/tianwanli01/Code/Go/gopath/src/golang.org/x/net/http2/transport.go:913 +0x101
golang.org/x/net/http2.(_ClientConn).forgetStreamID(0xc820082b00, 0xc800000001)
/home/users/tianwanli01/Code/Go/gopath/src/golang.org/x/net/http2/transport.go:904 +0x2e
golang.org/x/net/http2.(_ClientConn).RoundTrip(0xc820082b00, 0xc82060c000, 0xc8206ee480, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/gopath/src/golang.org/x/net/http2/transport.go:605 +0x600
golang.org/x/net/http2.(_Transport).RoundTripOpt(0xc8206308c0, 0xc82060c000, 0xc820045300, 0xc8204fc300, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/gopath/src/golang.org/x/net/http2/transport.go:263 +0x296
golang.org/x/net/http2.(_Transport).RoundTrip(0xc8206308c0, 0xc82060c000, 0x0, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/gopath/src/golang.org/x/net/http2/transport.go:238 +0x41
net/http.(_Transport).RoundTrip(0xc820748480, 0xc82060c000, 0xc820748480, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/go-go1.6/src/net/http/transport.go:318 +0x8e0
net/http.send(0xc82060c000, 0x7f87122d7528, 0xc820748480, 0x0, 0x0, 0x0, 0xc820634230, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/go-go1.6/src/net/http/client.go:260 +0x6b7
net/http.(_Client).send(0xc8206ef590, 0xc82060c000, 0x0, 0x0, 0x0, 0xd, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/go-go1.6/src/net/http/client.go:155 +0x185
net/http.(_Client).doFollowingRedirects(0xc8206ef590, 0xc82060c000, 0x9ff768, 0x0, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/go-go1.6/src/net/http/client.go:475 +0x8a4
net/http.(_Client).Do(0xc8206ef590, 0xc82060c000, 0xc, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/go-go1.6/src/net/http/client.go:191 +0x1e4
github.com/WanliTian/apns/vendor/github.com/RobotsAndPencils/buford/push.(_Service).PushBytes(0xc82010f760, 0xc8206fc200, 0x40, 0xc820475e78, 0xc82070a090, 0x65, 0x83, 0x0, 0x0, 0x0, ...)
/home/users/tianwanli01/Code/Go/gopath/src/github.com/WanliTian/apns/vendor/github.com/RobotsAndPencils/buford/push/service.go:173 +0x397
github.com/WanliTian/apns/vendor/github.com/RobotsAndPencils/buford/push.(_Service).Push(0xc82010f760, 0xc8206fc200, 0x40, 0xc820475e78, 0x7c7520, 0xc8207142a0, 0x0, 0x0, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/gopath/src/github.com/WanliTian/apns/vendor/github.com/RobotsAndPencils/buford/push/service.go:159 +0x105
main.(_Worker).start(0xc8206d6190)

When using this package, i got this error.

wrong certificate will cause this error.
is there any readable way to indicate this?

groob commented

If using the wrong certificate triggers the error, it's possible that you're running into the same issue here #33

Can you run your program with GODEBUG=http2debug=2 and add the debug information in your bug report?

This is the first time I've seen it cause a panic.

Please also check that dependencies such as net/http2 are up-to-date.

this happends again with the right certificate

ERROR: 2016/03/10 11:47:05 panic error : close of closed channel
ERROR: 2016/03/10 11:47:05 goroutine 47 [running]:
main.TraceStack()
/home/users/tianwanli01/Code/Go/gopath/src/github.com/WanliTian/apns/common_lib.go:84 +0x77
main.(_Worker).start.func1()
/home/users/tianwanli01/Code/Go/gopath/src/github.com/WanliTian/apns/worker.go:65 +0xbc
panic(0x7c8aa0, 0xc8206ab1a0)
/home/users/tianwanli01/Code/Go/go-go1.6/src/runtime/panic.go:426 +0x4e9
golang.org/x/net/http2.(_ClientConn).streamByID(0xc8205aa6e0, 0x100000003, 0x0)
/home/users/tianwanli01/Code/Go/gopath/src/golang.org/x/net/http2/transport.go:913 +0x101
golang.org/x/net/http2.(_ClientConn).forgetStreamID(0xc8205aa6e0, 0xc800000003)
/home/users/tianwanli01/Code/Go/gopath/src/golang.org/x/net/http2/transport.go:904 +0x2e
golang.org/x/net/http2.(_ClientConn).RoundTrip(0xc8205aa6e0, 0xc8208beee0, 0xc8209881e0, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/gopath/src/golang.org/x/net/http2/transport.go:605 +0x600
golang.org/x/net/http2.(_Transport).RoundTripOpt(0xc820675c00, 0xc8208beee0, 0xc820a21300, 0xc820aa1680, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/gopath/src/golang.org/x/net/http2/transport.go:263 +0x296
golang.org/x/net/http2.(_Transport).RoundTrip(0xc820675c00, 0xc8208beee0, 0xc8ffffffff, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/gopath/src/golang.org/x/net/http2/transport.go:238 +0x41
golang.org/x/net/http2.noDialH2RoundTripper.RoundTrip(0xc820675c00, 0xc8208beee0, 0xc820a99880, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/gopath/src/golang.org/x/net/http2/configure_transport.go:76 +0x3b
net/http.(_Transport).RoundTrip(0xc820482540, 0xc8208beee0, 0xc820482540, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/go-go1.6/src/net/http/transport.go:278 +0x352
net/http.send(0xc8208beee0, 0x7f789f30a528, 0xc820482540, 0x0, 0x0, 0x0, 0xc820a99960, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/go-go1.6/src/net/http/client.go:260 +0x6b7
net/http.(_Client).send(0xc8206f3320, 0xc8208beee0, 0x0, 0x0, 0x0, 0xd, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/go-go1.6/src/net/http/client.go:155 +0x185
net/http.(_Client).doFollowingRedirects(0xc8206f3320, 0xc8208beee0, 0x9ff780, 0x0, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/go-go1.6/src/net/http/client.go:475 +0x8a4
net/http.(_Client).Do(0xc8206f3320, 0xc8208beee0, 0xc, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/go-go1.6/src/net/http/client.go:191 +0x1e4
github.com/WanliTian/apns/vendor/github.com/RobotsAndPencils/buford/push.(_Service).PushBytes(0xc8205a5f00, 0xc820a9d8c0, 0x40, 0xc820ab5e78, 0xc820a18120, 0x64, 0x83, 0x0, 0x0, 0x0, ...)
/home/users/tianwanli01/Code/Go/gopath/src/github.com/WanliTian/apns/vendor/github.com/RobotsAndPencils/buford/push/service.go:173 +0x397
github.com/WanliTian/apns/vendor/github.com/RobotsAndPencils/buford/push.(_Service).Push(0xc8205a5f00, 0xc820a9d8c0, 0x40, 0xc820ab5e78, 0x7c7520, 0xc820aa17a0, 0x0, 0x0, 0x0, 0x0)
/home/users/tianwanli01/Code/Go/gopath/src/github.com/WanliTian/apns/vendor/github.com/RobotsAndPencils/buford/push/service.go:159 +0x105
main.(*Worker).start(0xc8206e7b30)

Did you look on line 84 of github.com/WanliTian/apns/common_lib.go?

There are no channels or calls to close channels in Buford itself. Of course there are channels in the net/http2 libraries though, but first of all, are you using channels in your own code?

82 func TraceStack() {
83 buf := make([]byte, 1<<16)
84 runtime.Stack(buf, true)
85 Errorf("%s", buf)
86 }

i use this code to print stacktrace

and what's at github.com/WanliTian/apns/worker.go:65?

I found that my net/http2 is too old.
i replace my net/http2 package and this error has not appeared for now.

i will watch it for a while.

awesome. please open a new issue if you run into any more problems

i find the wrong code for net/http2 package.
in the transport.go

//the newest package:
1057 func (cc *ClientConn) streamByID(id uint32, andRemove bool) *clientStream {
1058     cc.mu.Lock()
1059     defer cc.mu.Unlock()
1060     cs := cc.streams[id]
1061     if andRemove && cs != nil && !cc.closed {
1062         delete(cc.streams, id)
1063         close(cs.done)
1064     }
1065     return cs
1066 }

the old version
 907 func (cc *ClientConn) streamByID(id uint32, andRemove bool) *clientStream {
 908     cc.mu.Lock()
 909     defer cc.mu.Unlock()
 910     cs := cc.streams[id]
 911     if andRemove && cs != nil {
 912         delete(cc.streams, id)
 913         close(cs.done)
 914     }
 915     return cs
 916 }