pion / webrtc

Pure Go implementation of the WebRTC API
https://pion.ly
MIT License
13.9k stars 1.66k forks source link

nil pointer dereference in RTPReceiver readRTP #2929

Open LeeTeng2001 opened 1 month ago

LeeTeng2001 commented 1 month ago

Your environment.

goroutine 129 [running]: github.com/pion/webrtc/v3.(RTPReceiver).readRTP(0xc000414d80, {0xc000150600, 0x5b4, 0x5b4}, 0xc00077ea20) C:/Users/teng.lee/go/pkg/mod/github.com/pion/webrtc/v3@v3.2.40/rtpreceiver.go:369 +0xf7 github.com/pion/webrtc/v3.(TrackRemote).Read(0xc00077ea20, {0xc000150600, 0x5b4, 0x5b4}) C:/Users/teng.lee/go/pkg/mod/github.com/pion/webrtc/v3@v3.2.40/track_remote.go:139 +0x24e github.com/pion/webrtc/v3.(TrackRemote).peek(0xc00077ea20, {0xc000150600, 0x16?, 0x5b4}) C:/Users/teng.lee/go/pkg/mod/github.com/pion/webrtc/v3@v3.2.40/track_remote.go:191 +0x26 github.com/pion/webrtc/v3.(PeerConnection).startReceiver.func1(0xc00077ea20) C:/Users/teng.lee/go/pkg/mod/github.com/pion/webrtc/v3@v3.2.40/peerconnection.go:1241 +0x7a created by github.com/pion/webrtc/v3.(*PeerConnection).startReceiver in goroutine 105 C:/Users/teng.lee/go/pkg/mod/github.com/pion/webrtc/v3@v3.2.40/peerconnection.go:1239 +0x1e5 exit status 2


### What did you do?

Run pion with unsupported codec at remote? I'm not sure how to pin point the problem

### What did you expect?

ignore error and continue running

### What happened?

nil pointer dereference and panic

### Temporary solution

Right now, I added a check for rtcpinterceptor to be nil before returning, this is not ideal as I need to modify the source code

// readRTP should only be called by a track, this only exists so we can keep state in one place func (r RTPReceiver) readRTP(b []byte, reader TrackRemote) (n int, a interceptor.Attributes, err error) { <-r.received if t := r.streamsForTrack(reader); t != nil { if t.rtcpInterceptor == nil { return 0, nil, nil } return t.rtpInterceptor.Read(b, a) }

return 0, nil, fmt.Errorf("%w: %d", errRTPReceiverWithSSRCTrackStreamNotFound, reader.SSRC())

}

LeeTeng2001 commented 1 month ago

Might be related? #2322

Sean-Der commented 1 month ago

Nice find! Mind sending a PR @LeeTeng2001 would love to see this fixed :)

LeeTeng2001 commented 1 month ago

@Sean-Der mind reviewing my pr and merge it? thanks!

LeeTeng2001 commented 1 month ago

Hi I would like this issue to fix in v3, so should I merge to master or v3 ?