Skip to content

WebRTC: Fix race condition in RTC publish timer callbacks. v7.0.76#4470

Merged
winlinvip merged 3 commits intoossrs:developfrom
winlinvip:bugfix/rtc
Sep 3, 2025
Merged

WebRTC: Fix race condition in RTC publish timer callbacks. v7.0.76#4470
winlinvip merged 3 commits intoossrs:developfrom
winlinvip:bugfix/rtc

Conversation

@winlinvip
Copy link
Copy Markdown
Member

@winlinvip winlinvip commented Sep 3, 2025

WebRTC RTC publish streams use timer callbacks (SrsRtcPublishRtcpTimer and SrsRtcPublishTwccTimer) that can cause race conditions in SRS's coroutine-based architecture. The timer callbacks are heavy functions that may trigger coroutine switches, during which the timer object can be freed by another coroutine, leading to use-after-free crashes.

The race condition occurs because:

  1. Timer callbacks (on_timer) perform heavy operations that can yield control
  2. During coroutine switches, other coroutines may destroy the timer object
  3. When control returns, the callback continues executing on a freed object

Fixes potential crashes in WebRTC RTC publish streams under high concurrency.

@winlinvip winlinvip added the EnglishNative This issue is conveyed exclusively in English. label Sep 3, 2025
@winlinvip winlinvip changed the title RTX: Fix race condition for timer. RTX: Fix race condition for timer. v7.0.76 Sep 3, 2025
@winlinvip winlinvip added the RefinedByAI Refined by AI/GPT. label Sep 3, 2025
@winlinvip winlinvip changed the title RTX: Fix race condition for timer. v7.0.76 WebRTC: Fix race condition in RTC publish timer callbacks. v7.0.76 Sep 3, 2025
@winlinvip winlinvip merged commit 421ab6c into ossrs:develop Sep 3, 2025
14 checks passed
winlinvip added a commit that referenced this pull request Sep 5, 2025
See [WebRTC: Fix race condition in RTC publish timer
callbacks.](421ab6c)
v7.0.76 (#4470)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

EnglishNative This issue is conveyed exclusively in English. RefinedByAI Refined by AI/GPT.

Development

Successfully merging this pull request may close these issues.

1 participant