panic: runtime error: index out of range [0] with length 0
See original GitHub issuewhen I try the new version, it panic directly. here is log:
[GIN] 2021/04/09 - 10:28:52 | 200 | 160.161µs | 127.0.0.1 | GET "/static/js/app.js?ver=2021-04-09%2010%3a28%3a52.597377948%20%2b0800%20CST%20m%3d%2b54.595446870"
2021/04/09 10:28:52 Stream Try Connect MICRO
2021/04/09 10:28:53 [Recovery] 2021/04/09 - 10:28:53 panic recovered:
GET /stream/codec/MICRO HTTP/1.1
Host: localhost:8083
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7
Connection: keep-alive
Cookie: SL_G_WPT_TO=zh-CN; SL_GWPT_Show_Hide_tmp=undefined; SL_wptGlobTipTmp=undefined
Referer: http://localhost:8083/stream/player/MICRO
Sec-Ch-Ua: "Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"
Sec-Ch-Ua-Mobile: ?0
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36
X-Requested-With: XMLHttpRequest
runtime error: index out of range [0] with length 0
/home/lee/go/src/runtime/panic.go:88 (0x434fe4)
goPanicIndex: panic(boundsError{x: int64(x), signed: true, y: y, code: boundsIndex})
/home/lee/gowork/pkg/mod/github.com/deepch/vdk@v0.0.0-20210218105644-f6de3acad035/codec/h264parser/parser.go:516 (0xae3fb9)
CodecData.SPS: return self.RecordInfo.SPS[0]
/home/lee/test/RTSPtoWebRTC/config.go:156 (0xae3cf6)
(*ConfigST).coGe: if codecVideo.SPS() != nil && codecVideo.PPS() != nil && len(codecVideo.SPS()) > 0 && len(codecVideo.PPS()) > 0 {
/home/lee/test/RTSPtoWebRTC/http.go:67 (0xae5314)
HTTPAPIServerStreamCodec: codecs := Config.coGe(c.Param("uuid"))
/home/lee/gowork/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0xabcc9a)
(*Context).Next: c.handlers[c.index](c)
/home/lee/gowork/pkg/mod/github.com/gin-gonic/gin@v1.6.3/recovery.go:83 (0xad0c84)
RecoveryWithWriter.func1: c.Next()
/home/lee/gowork/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0xabcc9a)
(*Context).Next: c.handlers[c.index](c)
/home/lee/gowork/pkg/mod/github.com/gin-gonic/gin@v1.6.3/logger.go:241 (0xacfd84)
LoggerWithConfig.func1: c.Next()
/home/lee/gowork/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 (0xabcc9a)
(*Context).Next: c.handlers[c.index](c)
/home/lee/gowork/pkg/mod/github.com/gin-gonic/gin@v1.6.3/gin.go:409 (0xac6fd9)
(*Engine).handleHTTPRequest: c.Next()
/home/lee/gowork/pkg/mod/github.com/gin-gonic/gin@v1.6.3/gin.go:367 (0xac66cc)
(*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/home/lee/go/src/net/http/server.go:2843 (0x6ef582)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/home/lee/go/src/net/http/server.go:1925 (0x6eac8c)
(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/home/lee/go/src/runtime/asm_amd64.s:1374 (0x46cee0)
goexit: BYTE $0x90 // NOP
[GIN] 2021/04/09 - 10:28:53 | 500 | 51.389447ms | 127.0.0.1 | GET "/stream/codec/MICRO"
2021/04/09 10:28:53 RTSP Signal
2021/04/09 10:28:53 Stream Exit Rtsp Disconnect
2021/04/09 10:28:53 Stream Exit On Demand No Viewer
panic: runtime error: index out of range [0] with length 0
goroutine 198 [running]:
github.com/deepch/vdk/format/rtspv2.(*RTSPClient).RTPDemuxer(0xc00000c780, 0xc00000ef40, 0xc0001fa144, 0x40, 0x40, 0x40)
/home/lee/gowork/pkg/mod/github.com/deepch/vdk@v0.0.0-20210218105644-f6de3acad035/format/rtspv2/client.go:607 +0x2a66
github.com/deepch/vdk/format/rtspv2.(*RTSPClient).startStream(0xc00000c780)
/home/lee/gowork/pkg/mod/github.com/deepch/vdk@v0.0.0-20210218105644-f6de3acad035/format/rtspv2/client.go:290 +0x678
created by github.com/deepch/vdk/format/rtspv2.Dial
/home/lee/gowork/pkg/mod/github.com/deepch/vdk@v0.0.0-20210218105644-f6de3acad035/format/rtspv2/client.go:220 +0x79d
Process finished with exit code 2
it seems should check the length of nal byte array from the code line “for _, nal := range nalRaw {”
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Go “panic: runtime error: index out of range” when the length ...
The issue is that you are creating a slice with length 0 , but with a maximum capacity of ...
Read more >panic: runtime error: index out of range [0] with length 0 · Issue ...
This appears to be due to confusion between empty , the generic type, and empty , the local variable of the Next function....
Read more >Help: Index out of range · YourBasic Go
In the last iteration, i equals len(a) which is outside the bounds of a . Arrays, slices and strings are indexed starting from...
Read more >1924020 – panic: runtime error: index out of range [0] with ...
Using that as the default... panic: runtime error: index out of range [0] with length 0 goroutine 1 [running]: panic(0x56048dd710a0, 0xc00028ebe0) /usr/lib/ ...
Read more >go 1.6 sort panic: runtime error: index out of range
now causes a panic: runtime error: index out of range. ... go 1.6's sort may be broken. ... Less with i or j...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Modify the config.go line 186
to fix it.
@deepch Sorry, i need to close test stream for a several days. If you need the stream to test, just call me.