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

Fix payload size zero cause runtime panic on calculating padding size #277

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

tyohan
Copy link
Contributor

@tyohan tyohan commented Oct 7, 2024

I got runtime panic from this line when calculating the padding size but the payload size is zero.

My code is a simple WHIP WHEP but using NACK through webrtc.NewPeerConnection(). This is happen when a browser publish a stream to WHIP endpoint and another browser trying to subscribe using WHEP.

Exception has occurred: panic
"runtime error: index out of range [-1]"
Stack:
	 3  0x0000000102a8d4d8 in github.com/pion/interceptor/pkg/nack.(*packetManager).NewPacket
	     at /Users/tyohan/go/pkg/mod/github.com/pion/[email protected]/pkg/nack/retainable_packet.go:82
	 4  0x0000000102a8c4b8 in github.com/pion/interceptor/pkg/nack.(*ResponderInterceptor).BindLocalStream.func1
	     at /Users/tyohan/go/pkg/mod/github.com/pion/[email protected]/pkg/nack/responder_interceptor.go:118
	 5  0x000000010290f3ac in github.com/pion/interceptor.RTPWriterFunc.Write
	     at /Users/tyohan/go/pkg/mod/github.com/pion/[email protected]/interceptor.go:86
	 6  0x0000000102a92d60 in github.com/pion/interceptor/pkg/report.(*SenderInterceptor).BindLocalStream.func1
	     at /Users/tyohan/go/pkg/mod/github.com/pion/[email protected]/pkg/report/sender_interceptor.go:144
	 7  0x000000010290f3ac in github.com/pion/interceptor.RTPWriterFunc.Write
	     at /Users/tyohan/go/pkg/mod/github.com/pion/[email protected]/interceptor.go:86
	 8  0x0000000102abcba0 in github.com/pion/webrtc/v4.(*interceptorToTrackLocalWriter).WriteRTP
	     at /Users/tyohan/go/pkg/mod/github.com/pion/webrtc/[email protected]/interceptor.go:147
	 9  0x0000000102afd244 in github.com/pion/webrtc/v4.(*TrackLocalStaticRTP).writeRTP
	     at /Users/tyohan/go/pkg/mod/github.com/pion/webrtc/[email protected]/track_local_static.go:172
	10  0x0000000102afd4d0 in github.com/pion/webrtc/v4.(*TrackLocalStaticRTP).Write
	     at /Users/tyohan/go/pkg/mod/github.com/pion/webrtc/[email protected]/track_local_static.go:193
	11  0x0000000102b0e3a0 in inlive.dev/live/internal/channel.NewRemoteTrack.func1
	     at /Users/tyohan/Dev/inLive/live/internal/channel/remotetrack.go:60

This PR will fix the issue

@tyohan tyohan added the bug Something isn't working label Oct 7, 2024
@tyohan tyohan requested a review from Sean-Der October 7, 2024 02:15
@tyohan tyohan changed the title Fix zero payload size cause panic Fix payload size zero cause runtime panic on calculating padding size Oct 7, 2024
Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 72.87%. Comparing base (bfda3e0) to head (f074cca).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/nack/retainable_packet.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #277      +/-   ##
==========================================
+ Coverage   72.81%   72.87%   +0.05%     
==========================================
  Files          79       79              
  Lines        3679     3679              
==========================================
+ Hits         2679     2681       +2     
+ Misses        866      865       -1     
+ Partials      134      133       -1     
Flag Coverage Δ
go 72.76% <0.00%> (-0.06%) ⬇️
wasm 70.99% <0.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Sean-Der Sean-Der merged commit 0eab188 into master Oct 7, 2024
14 of 15 checks passed
@Sean-Der Sean-Der deleted the fix/padding-size-calc-panic branch October 7, 2024 02:36
@Sean-Der
Copy link
Member

Sean-Der commented Oct 7, 2024

Oops, thank you so much @tyohan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

2 participants