Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nil pointer dereference panic after network reconnect #678

Closed
SijmenHuizenga opened this issue Jan 13, 2025 · 2 comments
Closed

nil pointer dereference panic after network reconnect #678

SijmenHuizenga opened this issue Jan 13, 2025 · 2 comments

Comments

@SijmenHuizenga
Copy link
Contributor

I'm seeing a nullpointer dereference panic at this file at line 1928:

gortsplib/client.go

Lines 1909 to 1936 in c308cb3

func (c *Client) WritePacketRTPWithNTP(medi *description.Media, pkt *rtp.Packet, ntp time.Time) error {
byts := make([]byte, c.MaxPacketSize)
n, err := pkt.MarshalTo(byts)
if err != nil {
return err
}
byts = byts[:n]
select {
case <-c.done:
return c.closeError
default:
}
cm := c.setuppedMedias[medi]
cf := cm.formats[pkt.PayloadType]
cf.rtcpSender.ProcessPacketRTP(pkt, ntp, cf.format.PTSEqualsDTS(pkt))
ok := c.writer.push(func() error {
return cf.writePacketRTPInQueue(byts)
})
if !ok {
return liberrors.ErrClientWriteQueueFull{}
}
return nil
}

It happens when the connection is harshly broken as a result of a network disruption.

I suspect there is some race condition caused by this line:

c.writer = nil

The trace is:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xb4a308]

goroutine 14 [running]:
github.com/bluenviron/gortsplib/v4.(*asyncProcessor).push(...)
	/home/ascento/go/pkg/mod/github.com/bluenviron/gortsplib/v4@v4.12.1/async_processor.go:58
github.com/bluenviron/gortsplib/v4.(*Client).WritePacketRTPWithNTP(0x4000544fc8, 0x400054e0a0, 0x40007e07a0, {0x5f3a38?, 0x40008ebaa8?, 0x15253c0?})
	/home/ascento/go/pkg/mod/github.com/bluenviron/gortsplib/v4@v4.12.1/client.go:1928 +0x178
@SijmenHuizenga SijmenHuizenga changed the title nil pointer dereference panic when writing while closing nil pointer dereference panic after network reconnect Jan 17, 2025
@SijmenHuizenga
Copy link
Contributor Author

SijmenHuizenga commented Jan 17, 2025

I've been trying to pinpoint the cause, and my current best guess is that this is introduced in #655

Unrelated: The work in #655 is a huge step forward of working in poor network connectivity areas. Looking forward to being able to roll it out after fixing this issue.

@aler9
Copy link
Member

aler9 commented Jan 18, 2025

Fixed by #655

@aler9 aler9 closed this as completed Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants