Comments (7)
看起来有点像是 flvWriter.SendPacket
和 flvWriter.Close
的竞争条件,这里给一个推测,不一定正确:
- Go 的
http
库会在 Handler 返回的时候,调用response.finishRequest
方法,这个方法会调用response
内部的bufio.Writer
的Reset(nil)
。 - 一般而言,
httpflv/server.handleConn
会等待flvWriter
结束。 flvWriter.Close
会关闭packetQueue
和closedChan
,后者让handleConn
结束,前者让SendPacket
结束。
但是,SendPacket
在发送之前并不会检查自身是否已经结束:
livego/protocol/httpflv/writer.go
Lines 140 to 146 in bf65635
所以,假如说有以下的执行序列:
- 某处调用
flvWriter.Close
。 handleConn
发现closedChan
关闭,返回;http 库执行finishRequest
。- 此时,
SendPacket
进入了这个分支:
livego/protocol/httpflv/writer.go
Lines 110 to 130 in bf65635
- 在执行到
livego/protocol/httpflv/writer.go
Line 140 in bf65635
或者
livego/protocol/httpflv/writer.go
Line 144 in bf65635
的时候,就可能会遇到往空 io.Writer 写数据的 panic。
from livego.
请提供错误详细堆栈
from livego.
2017/06/16 10:20:37 writer.go:159: http flv closed
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x501558]
goroutine 4988871 [running]:
bufio.(*Writer).Flush(0xc420012b00, 0xc422c98d44, 0x6e9)
/usr/local/Cellar/go/1.8.3/libexec/src/bufio/bufio.go:566 +0x58
bufio.(*Writer).Write(0xc420012b00, 0xc422c98d44, 0x2620, 0x622bc, 0xb, 0x0, 0x0)
/usr/local/Cellar/go/1.8.3/libexec/src/bufio/bufio.go:602 +0xdf
net/http.(*response).write(0xc420180540, 0x2620, 0xc422c98d44, 0x2620, 0x622bc, 0x0, 0x0, 0xb, 0x0, 0x0)
/usr/local/Cellar/go/1.8.3/libexec/src/net/http/server.go:1525 +0x150
net/http.(*response).Write(0xc420180540, 0xc422c98d44, 0x2620, 0x622bc, 0xb, 0x0, 0x0)
/usr/local/Cellar/go/1.8.3/libexec/src/net/http/server.go:1495 +0x64
github.com/gwuhaolin/livego/protocol/httpflv.(*FLVWriter).SendPacket(0xc4200f6240, 0x0, 0x0)
/Users/halwu/go/src/github.com/gwuhaolin/livego/protocol/httpflv/writer.go:134 +0x20c
github.com/gwuhaolin/livego/protocol/httpflv.NewFLVWriter.func1(0xc4200f6240)
/Users/halwu/go/src/github.com/gwuhaolin/livego/protocol/httpflv/writer.go:47 +0x2f
created by github.com/gwuhaolin/livego/protocol/httpflv.NewFLVWriter
/Users/halwu/go/src/github.com/gwuhaolin/livego/protocol/httpflv/writer.go:52 +0x387
from livego.
我找到重现的方法了。一直调用,用火狐测试大概是27个小时多一点的时候,就会出现这个错误。
from livego.
@gwuhaolin 这个问题解决了吗?
from livego.
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x63f603]
goroutine 77131459 [running]:
bufio.(*Writer).Flush(0xc004717800, 0xc00579f94e, 0x61)
c:/go/src/bufio/bufio.go:591 +0x63
bufio.(*Writer).Write(0xc004717800, 0xc00579f94e, 0x1dd, 0x236b2, 0xb, 0x0, 0x0)
c:/go/src/bufio/bufio.go:627 +0x101
net/http.(*response).write(0xc0002b6c40, 0x1dd, 0xc00579f94e, 0x1dd, 0x236b2, 0x0, 0x0, 0xb, 0x0, 0x0)
c:/go/src/net/http/server.go:1578 +0x2dc
net/http.(*response).Write(0xc0002b6c40, 0xc00579f94e, 0x1dd, 0x236b2, 0xb, 0x0, 0x0)
c:/go/src/net/http/server.go:1547 +0x5d
github.com/gwuhaolin/livego/protocol/httpflv.(*FLVWriter).SendPacket(0xc001420000, 0xa8bb28, 0xc00324f1e0)
C:/Users/renzo/code/nslive/protocol/httpflv/writer.go:144 +0x198
github.com/gwuhaolin/livego/protocol/httpflv.NewFLVWriter.func1(0xc001420000)
C:/Users/renzo/code/nslive/protocol/httpflv/writer.go:49 +0x36
created by github.com/gwuhaolin/livego/protocol/httpflv.NewFLVWriter
C:/Users/renzo/code/nslive/protocol/httpflv/writer.go:48 +0x362
使用6路推流原画时,当推流速度很小的情况下(测试时约为0.6x),会出现以上错误
from livego.
时不时会出现这个问题,但是没找到出现的规律。这个问题有解决方案了吗?
`
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x50ada2]
goroutine 153 [running]:
bufio.(*Writer).Flush(0xc0000d5bc0, 0xc0011dfbef, 0x7f5)
G:/Program Files/Go/src/bufio/bufio.go:607 +0x62
bufio.(*Writer).Write(0xc0000d5bc0, 0xc0011dfbef, 0x2981, 0x5b411, 0xb, 0x0, 0x0)
G:/Program Files/Go/src/bufio/bufio.go:643 +0xfc
net/http.(*response).write(0xc00021c2a0, 0x2981, 0xc0011dfbef, 0x2981, 0x5b411, 0x0, 0x0, 0xb, 0x0, 0x0)
G:/Program Files/Go/src/net/http/server.go:1615 +0x38a
net/http.(*response).Write(0xc00021c2a0, 0xc0011dfbef, 0x2981, 0x5b411, 0xb, 0x0, 0x0)
G:/Program Files/Go/src/net/http/server.go:1573 +0x56
github.com/gwuhaolin/livego/protocol/httpflv.(*FLVWriter).SendPacket(0xc0000c4000, 0x7fc2f1b3f028, 0xc0000765a0)
E:/go/src/livego/protocol/httpflv/writer.go:151 +0x198
github.com/gwuhaolin/livego/protocol/httpflv.NewFLVWriter.func1(0xc0000c4000)
E:/go/src/livego/protocol/httpflv/writer.go:55 +0x2f
created by github.com/gwuhaolin/livego/protocol/httpflv.NewFLVWriter
E:/go/src/livego/protocol/httpflv/writer.go:54 +0x35f
`
from livego.
Related Issues (20)
- 优化文档
- 有没有restful api 控制录像开始和结束
- Bug: 房间号既可以是key, key也可以是房间号
- Is this project still under maintenance? | 这个项目仍在维护吗? HOT 3
- 请问怎么在线看直播内容? HOT 1
- Does liveGo have support live with mutil tenant?
- /protocol/rtmp/rtmp.go NewRtmpClient 能做客户端推流吗,
- panic: runtime error: invalid memory address or nil pointer dereference
- StartStaticPush: staticpushObj.Start rtmp://user:pass@ip:1935/app/name error=EOF HOT 1
- 请求docker支持arm HOT 1
- 关于procotol/rtmp/stream.go中的TransStart()函数的问题
- 关于protocol/rmtp/stream.go下的TransStart()函数的问题 HOT 1
- re use channelkey HOT 1
- can not play rtmp in vlc HOT 1
- SRT transport
- .mp3 url or similar audio format HOT 1
- 持续推流中断 转FLV
- VOD use case
- flv 存储路径
- Is creating an appname with a slash ("/") character possible? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from livego.