slice bounds out of range panic
panic: runtime error: slice bounds out of range [:333] with capacity 299
goroutine 4361379 [running]: bytes.(*Buffer).grow(0xc1acae3b00, 0xf) /var/jenkins_home/go/go1.17.9/src/bytes/buffer.go:148 +0x226 bytes.(*Buffer).Write(0xc1acae3b00, {0xc1acce4c90, 0xf, 0xc10482a9d0}) /var/jenkins_home/go/go1.17.9/src/bytes/buffer.go:172 +0x66 github.com/imroc/req/v3/internal/dump.(*Dumper).Dump(0xc1acb608e8, {0xc1acce4c90, 0xf, 0x10}) /root/go/pkg/mod/github.com/imroc/req/[email protected]/internal/dump/dump.go:138 +0xd6 github.com/imroc/req/v3/internal/http2.(*Framer).readMetaFrame.func2({{0x1ed12ff, 0x6}, {0xc1acce4c59, 0x5}, 0x0}) /root/go/pkg/mod/github.com/imroc/req/[email protected]/internal/http2/frame.go:1593 +0x118 golang.org/x/net/http2/hpack.(*Decoder).callEmit(0xc1ac8b9a40, {{0x1ed12ff, 0x6}, {0xc1acce4c59, 0x5}, 0x0}) /root/go/pkg/mod/golang.org/x/[email protected]/http2/hpack/hpack.go:393 +0x8d golang.org/x/net/http2/hpack.(*Decoder).parseFieldLiteral(0xc1ac8b9a40, 0x28, 0x0) /root/go/pkg/mod/golang.org/x/[email protected]/http2/hpack/hpack.go:383 +0x298 golang.org/x/net/http2/hpack.(*Decoder).parseHeaderFieldRepr(0x0) /root/go/pkg/mod/golang.org/x/[email protected]/http2/hpack/hpack.go:316 +0x107 golang.org/x/net/http2/hpack.(*Decoder).Write(0xc1ac8b9a40, {0xc1cca18580, 0xb7, 0x8}) /root/go/pkg/mod/golang.org/x/[email protected]/http2/hpack/hpack.go:262 +0x132 github.com/imroc/req/v3/internal/http2.(*Framer).readMetaFrame(0xc1ae01d770, 0xc1acceed80, {0xc1e7b91cf8, 0x1, 0x1}) /root/go/pkg/mod/github.com/imroc/req/[email protected]/internal/http2/frame.go:1606 +0x3b1 github.com/imroc/req/v3/internal/http2.(*Framer).ReadFrame(0xc1ae01d770) /root/go/pkg/mod/github.com/imroc/req/[email protected]/internal/http2/frame.go:540 +0x559 github.com/imroc/req/v3/internal/http2.(*clientConnReadLoop).run(0xc10482af98) /root/go/pkg/mod/github.com/imroc/req/[email protected]/internal/http2/transport.go:2081 +0x131 github.com/imroc/req/v3/internal/http2.(*ClientConn).readLoop(0xc1ad5da480) /root/go/pkg/mod/github.com/imroc/req/[email protected]/internal/http2/transport.go:1977 +0x6f created by github.com/imroc/req/v3/internal/http2.(*Transport).newClientConn /root/go/pkg/mod/github.com/imroc/req/[email protected]/internal/http2/transport.go:657 +0xae5
See that the error is related to dump. How do you use dump?
Is there code to reproduce it?
fmClient := req.C().
SetTimeout(time.Second * 3).
EnableTraceAll().
SetCommonRetryCount(1)
resp, err := fmClient.R().
SetBodyJsonMarshal(data).
EnableDump().
EnableTrace().
Post(domain + getToken)
if err != nil {
return res, err
}
respCode := gjson.Get(resp.String(), "errcode").Int()
if respCode != 0 {
logger.ErrLogger().WithFields(logrus.Fields{
"resp": resp.Dump(),
}).Errorf("request invalid resp err")
return res, requestErr
}
Can't reproduce in my environment, looking at the stack of panic, the bytes.Buffer of go1.17.9 is out of range when grow().
Has the go standard library used for compilation been modified? Or upgrade the standard library to the latest version and try again.