Skip to content

Fix segfault in play media with record-egress enabled#2086

Closed
fergusean wants to merge 1 commit intosipwise:masterfrom
fergusean:fix/fix-play-media-segfault
Closed

Fix segfault in play media with record-egress enabled#2086
fergusean wants to merge 1 commit intosipwise:masterfrom
fergusean:fix/fix-play-media-segfault

Conversation

@fergusean
Copy link
Contributor

Summary

Fix a segmentation fault that occurred when issuing a "play media" command while call recording with --record-egress was active.

Root Cause

When the media player constructed a synthetic struct media_packet for the egress-recording path in media_player.c, it left the media field uninitialized (NULL). The dump_packet_pcap() function in recording.c then unconditionally dereferenced mp->media->monologue, causing a segfault.

Changes Made

  • daemon/media_player.c: Initialize the media field in the synthetic struct media_packet to sink->media when constructing packets for the media player send timer. This ensures the media context is available for the egress recording path.

  • daemon/recording.c: Add a defensive NULL check in dump_packet_pcap() to safely handle cases where mp->media or mp->media->monologue might be NULL, preventing crashes from incomplete packet structures.

  • t/auto-daemon-tests-record-egress-play-media.pl: Add comprehensive regression test covering:

    • Play media with active call recording
    • Daemon stability after play media completes
    • RTP forwarding resumption after media playback
    • Play media in both directions (from-tag and to-tag)
    • Stop media during egress recording
    • Play media across multiple independent calls

Testing

The new test verifies the fix works correctly and prevents regression of this crash scenario when using --record-egress with the play media feature.

sipwise-jenkins pushed a commit that referenced this pull request Mar 24, 2026
Closes #2086

Change-Id: Iad7b7297b2b24a76ca60f81393d6215c92dff612
(cherry picked from commit ff07591)
sipwise-jenkins pushed a commit that referenced this pull request Mar 24, 2026
Closes #2086

Change-Id: Iad7b7297b2b24a76ca60f81393d6215c92dff612
(cherry picked from commit ff07591)
sipwise-jenkins pushed a commit that referenced this pull request Mar 24, 2026
Closes #2086

Change-Id: Iad7b7297b2b24a76ca60f81393d6215c92dff612
(cherry picked from commit ff07591)
sipwise-jenkins pushed a commit that referenced this pull request Mar 24, 2026
Closes #2086

Change-Id: Iad7b7297b2b24a76ca60f81393d6215c92dff612
(cherry picked from commit ff07591)
(cherry picked from commit aef984d)
sipwise-jenkins pushed a commit that referenced this pull request Mar 24, 2026
Closes #2086

Change-Id: Iad7b7297b2b24a76ca60f81393d6215c92dff612
(cherry picked from commit ff07591)
(cherry picked from commit 1cf7f60)
sipwise-jenkins pushed a commit that referenced this pull request Mar 24, 2026
Closes #2086

Change-Id: Iad7b7297b2b24a76ca60f81393d6215c92dff612
(cherry picked from commit ff07591)
(cherry picked from commit cdf3625)
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

Successfully merging this pull request may close these issues.

1 participant