diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index e6c2ee097d2..f0048ec230c 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 7.0 Changelog +* v7.0, 2025-09-05, Merge [#4474](https://github.com/ossrs/srs/pull/4474): WebRTC: Fix race condition in RTC nack timer callbacks. v7.0.79 (#4474) * v7.0, 2025-09-04, Merge [#4467](https://github.com/ossrs/srs/pull/4467): WebRTC: Fix NACK recovered packets not being added to receive queue. v7.0.78 (#4467) * v7.0, 2025-09-03, Merge [#4469](https://github.com/ossrs/srs/pull/4469): Upgrade HTTP parser from http-parser to llhttp. v7.0.77 (#4469) * v7.0, 2025-09-03, Merge [#4470](https://github.com/ossrs/srs/pull/4470): RTX: Fix race condition for timer. v7.0.76 (#4470) diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index 07adce7d015..144392688f4 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -1745,18 +1745,29 @@ void SrsRtcPublishStream::update_send_report_time(uint32_t ssrc, const SrsNtp &n SrsRtcConnectionNackTimer::SrsRtcConnectionNackTimer(SrsRtcConnection *p) : p_(p) { + lock_ = srs_mutex_new(); _srs_shared_timer->timer20ms()->subscribe(this); } SrsRtcConnectionNackTimer::~SrsRtcConnectionNackTimer() { - _srs_shared_timer->timer20ms()->unsubscribe(this); + if (true) { + SrsLocker(lock_); + _srs_shared_timer->timer20ms()->unsubscribe(this); + } + srs_mutex_destroy(lock_); } srs_error_t SrsRtcConnectionNackTimer::on_timer(srs_utime_t interval) { srs_error_t err = srs_success; + // This is a very heavy function, and it may potentially cause a coroutine switch. + // Therefore, during this function, the 'this' pointer might become invalid because + // the object could be freed by another thread. As a result, we must lock the object + // to prevent it from being freed. + SrsLocker(lock_); + if (!p_->nack_enabled_) { return err; } diff --git a/trunk/src/app/srs_app_rtc_conn.hpp b/trunk/src/app/srs_app_rtc_conn.hpp index 3842bf6f617..98dcb7acc6a 100644 --- a/trunk/src/app/srs_app_rtc_conn.hpp +++ b/trunk/src/app/srs_app_rtc_conn.hpp @@ -454,6 +454,7 @@ class SrsRtcConnectionNackTimer : public ISrsFastTimer { private: SrsRtcConnection *p_; + srs_mutex_t lock_; public: SrsRtcConnectionNackTimer(SrsRtcConnection *p); diff --git a/trunk/src/core/srs_core_version7.hpp b/trunk/src/core/srs_core_version7.hpp index fac2c933098..d03d1a01f51 100644 --- a/trunk/src/core/srs_core_version7.hpp +++ b/trunk/src/core/srs_core_version7.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 7 #define VERSION_MINOR 0 -#define VERSION_REVISION 78 +#define VERSION_REVISION 79 #endif \ No newline at end of file