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

muxer: fix nil deref when finalizing muxerSegmentFMP4 with no currentPart #136

Closed
wants to merge 1 commit into from

Conversation

database64128
Copy link

@database64128 database64128 commented Jan 24, 2024

Playing an AV1 + AAC HLS stream published by OBS Studio via RTMP results in the following panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x560447ec0e43]
goroutine 663 [running]:
github.com/bluenviron/gohlslib.(*muxerSegmentFMP4).finalize(0xc0006101c0, 0x0)
        github.com/bluenviron/gohlslib@v1.2.1/muxer_segment_fmp4.go:83 +0x23
github.com/bluenviron/gohlslib.(*muxerSegmenterFMP4).close(0xc00016a240)
        github.com/bluenviron/gohlslib@v1.2.1/muxer_segmenter_fmp4.go:131 +0x29
github.com/bluenviron/gohlslib.(*Muxer).Close(0xc000404140)
        github.com/bluenviron/gohlslib@v1.2.1/muxer.go:202 +0x38
github.com/bluenviron/mediamtx/internal/servers/hls.(*muxer).runInner(0xc0002a0120, {0x560448714258, 0xc0003da500}, 0xc0011f3fa0?)
        github.com/bluenviron/mediamtx/internal/servers/hls/muxer.go:288 +0xb30
github.com/bluenviron/mediamtx/internal/servers/hls.(*muxer).run.func1.1.1()
        github.com/bluenviron/mediamtx/internal/servers/hls/muxer.go:140 +0x32
created by github.com/bluenviron/mediamtx/internal/servers/hls.(*muxer).run.func1.1 in goroutine 662
        github.com/bluenviron/mediamtx/internal/servers/hls/muxer.go:139 +0x170

This commit addresses the panic, but does not fix the underlying issue with this particular codec combination.

…Part

Playing an AV1 + AAC HLS stream published by OBS Studio via RTMP results in the following panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x560447ec0e43]
goroutine 663 [running]:
github.com/bluenviron/gohlslib.(*muxerSegmentFMP4).finalize(0xc0006101c0, 0x0)
        github.com/bluenviron/gohlslib@v1.2.1/muxer_segment_fmp4.go:83 +0x23
github.com/bluenviron/gohlslib.(*muxerSegmenterFMP4).close(0xc00016a240)
        github.com/bluenviron/gohlslib@v1.2.1/muxer_segmenter_fmp4.go:131 +0x29
github.com/bluenviron/gohlslib.(*Muxer).Close(0xc000404140)
        github.com/bluenviron/gohlslib@v1.2.1/muxer.go:202 +0x38
github.com/bluenviron/mediamtx/internal/servers/hls.(*muxer).runInner(0xc0002a0120, {0x560448714258, 0xc0003da500}, 0xc0011f3fa0?)
        github.com/bluenviron/mediamtx/internal/servers/hls/muxer.go:288 +0xb30
github.com/bluenviron/mediamtx/internal/servers/hls.(*muxer).run.func1.1.1()
        github.com/bluenviron/mediamtx/internal/servers/hls/muxer.go:140 +0x32
created by github.com/bluenviron/mediamtx/internal/servers/hls.(*muxer).run.func1.1 in goroutine 662
        github.com/bluenviron/mediamtx/internal/servers/hls/muxer.go:139 +0x170

This commit addresses the panic, but does not fix the underlying issue with this particular codec combination.
Copy link

codecov bot commented Jan 24, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (7413f03) 72.05% compared to head (c614797) 72.00%.

Files Patch % Lines
muxer_segment_fmp4.go 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #136      +/-   ##
==========================================
- Coverage   72.05%   72.00%   -0.06%     
==========================================
  Files          43       43              
  Lines        3822     3825       +3     
==========================================
  Hits         2754     2754              
- Misses        852      854       +2     
- Partials      216      217       +1     

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

aler9 added a commit that referenced this pull request Jan 25, 2024
@aler9
Copy link
Member

aler9 commented Jan 25, 2024

Hello, thanks for posting the crash dump. I was able to replicate the issue, and in my case it happened when hlsDirectory is not empty and it points to an invalid directory. A more complete fix was added with #137. Please let me know if it solves the crash.

@aler9 aler9 closed this Jan 25, 2024
@database64128
Copy link
Author

Thanks. I can confirm that #137 does fix the issue for me.

@database64128 database64128 deleted the muxer-nil-deref branch January 25, 2024 14:24
@github-actions github-actions bot locked and limited conversation to collaborators Jul 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants