Monibuca / engine

Monibuca 核心引擎,包含流媒体核心转发逻辑,需要配合功能插件一起组合运行
MIT License
953 stars 201 forks source link

运行一段时间后,空指针导致panic退出 #79

Closed hydaizd closed 1 year ago

hydaizd commented 1 year ago

版本:v4.12.0 util/list.go文件中,在Push方法中调用p.Pre.InsertAfter(item),p.Pre为空指针,导致在调用InsertAfter方法时,代码行:insert.list = item.list,item空指针导致程序异常退出。

func (p *List[T]) Push(item *ListItem[T]) {
    if item.list != nil {
        panic("item already in list")
    }
    if p.Length == 0 {
        p.Next = &p.ListItem
        p.Pre = &p.ListItem
        p.ListItem.list = p
    }
    p.Pre.InsertAfter(item)
}

func (item *ListItem[T]) InsertAfter(insert *ListItem[T]) {
    if insert.list != nil {
        panic("item already in list")
    }
    insert.list = item.list
    insert.Next = item.Next
    insert.Pre = item
    item.Next.Pre = insert
    item.Next = insert
    item.list.Length++
}
langhuihui commented 1 year ago

ok

langhuihui commented 1 year ago

理论上pre为空的话p.Length == 0也应该成立,方便打个断点看一下吗?

hydaizd commented 1 year ago

当时看的时候p.Length的值为24,不是0,等复现再截图发上来给你看下

langhuihui commented 1 year ago

有复现路径吗?最好我能本地复现就好弄了

hydaizd commented 1 year ago

重现了的话我把整个调用路径记下来,之前是在调用Recycle方法里面进入的。

langhuihui commented 1 year ago

👌,多谢

langhuihui commented 1 year ago

安排在4.5.3 中解决