HTTP hook callback segmentation fault - srs_app_rtmp_conn.cpp
Hi. I think I found the issue - an uninitialized pointer in SrsRtmpConn.
SrsRtmpConn has a per-connection health-tracking member that the hook-deny path never sets: src/app/srs_app_rtmp_conn.hpp:240 — SrsLiveConsumer *consumer_; (raw pointer, only assigned in playing() at srs_app_rtmp_conn.cpp:742) The constructor SrsRtmpConn::SrsRtmpConn() (srs_app_rtmp_conn.cpp:208) never initialized it.
The crash chain: stream_service_cycle() calls stat_->on_client(...) at srs_app_rtmp_conn.cpp:605 (before the hook, so the hook payload can contain stream_id/clients) → the player is now in SrsStatistic::clients_. http_hooks_on_play() (line 612) does the blocking POST → the coroutine yields. dynamic_cast<SrsRtmpConn*> succeeds, is_playing() is true (type is set before the hook) → if (consumer_) is true for the stale recycled-heap garbage → consumer_->get_jitter_metrics() dereferences it → SIGSEGV.
Proposed fix:
- add in constructor (~linie225) consumer_ = NULL;
- add (~line 223) bandwidth_ = NULL; (dead, uninitialized member at srs_app_rtmp_conn.hpp:198: the SrsUniquePtr frees the consumer, then stream_service_cycle() calls http_hooks_on_stop() (another POST that yields), so the API could read a dangling consumer_ for a normally-stopped player.)
- set_consumer(NULL); at the end of playing() (~line 773)
Could you please confirm?
Source: ossrs/srs