braice / MuMuDVB

A DVB IPTV streaming software
http://mumudvb.braice.net/
GNU General Public License v2.0
216 stars 133 forks source link

DVB-T channels down. Cannot gracefully exit mumudvb. #305

Closed pszemus closed 1 year ago

pszemus commented 1 year ago

Hello

I've been using mumudvb for quite long time without any problems, until recently when the broadcaster added some new channels (virtual, HbbTv - don't know if relevant). After that mumudvb stopped receiving any channels (however it detects and lists them) and cannot be closed gracefully (SIGTERM & SIGINT don't work, only SIGKILL does).

I have that same issue on hosts in several geographical locations and 2 different DVB-T cards (same kernel though: 5.13.6-1.el7.elrepo.x86_64). I'm using the lastest mumudvb build from git.

freq=522000
delivery_system=DVBT
autoconfiguration=full
multicast_iface4=lo
autoconf_ip4=239.100.%card.%sid_lo
$ sudo mumudvb -d --card 1 --config /tmp/mux3.conf 
MuMuDVB Version 2.1.0
 --- Build information ---
Built without CAM support.
Built without SCAM support.
Built with ATSC support.
Built with support for DVB API Version 5.11.
Built with support for DVB-T2.
---------
Originally based on dvbstream 0.6 by (C) Dave Chapman 2001-2004
Released under the GPL.
Latest version available from http://mumudvb.net/
Project from the cr@ns (http://www.crans.org)
by Brice DUBOST (mumudvb@braice.net)

Info:  Tune:  You will use DVB API version 5 for tuning your card.
Info:  Main:  Autoconfiguration, we activate SAP announces. if you want to disable them see the README.
Info:  Main:  Autoconfiguration, we activate PAT rewriting. if you want to disable it see the README.
Info:  Main:  Autoconfiguration, we activate SDT rewriting. if you want to disable it see the README.
Info:  Main:  ========== End of configuration, MuMuDVB version 2.1.0 is starting ==========
Info:  Main:  Streaming. Freq 522000000.000000
Info:  Tune:  Using DVB card "TurboSight TBS 6281SE DVB-T/T2/C " tuner 0
Info:  Tune:  Tuning Terrestrial to 522000000 Hz, Bandwidth: 8000000
Info:  Tune:  Tuning With DVB-API version 5. delivery system : 3
Info:  Tune:  FE_STATUS:
Info:  Tune:  FE_STATUS:
Info:  Tune:       FE_HAS_SIGNAL : found something above the noise level
Info:  Tune:       FE_HAS_CARRIER : found a DVB signal
Info:  Tune:       FE_HAS_VITERBI : FEC is stable
Info:  Tune:       FE_HAS_SYNC : found sync bytes
Info:  Tune:       FE_HAS_LOCK : everything's working... 
Info:  Tune:  Event:  Frequency: 3
Info:  Tune:  Bit error rate: 0
Info:  Tune:  Signal strength: 46576
Info:  Tune:  SNR: 37392
Info:  Main:  Card 1, tuner 0 tuned
main 0x63dca0
Info:  Common chan:  Looking through all services to update their filters
Info:  Autoconf:  Autoconfiguration is now ready to work for you !
Info:  Autoconf:  The PAT version changed, channels have changed
Info:  Autoconf:  New PAT we force SDT update after all sections seen
WARN:  Autoconf:  Channel 0 SID 1 Force PMT update
WARN:  Autoconf:  Channel 1 SID 2 Force PMT update
WARN:  Autoconf:  Channel 2 SID 21 Force PMT update
WARN:  Autoconf:  Channel 3 SID 32 Force PMT update
WARN:  Autoconf:  Channel 4 SID 33 Force PMT update
WARN:  Autoconf:  Channel 5 SID 35 Force PMT update
WARN:  Autoconf:  Channel 6 SID 92 Force PMT update
WARN:  Autoconf:  Channel 7 SID 93 Force PMT update
WARN:  Autoconf:  Channel 8 SID 94 Force PMT update
Info:  Autoconf:  The NIT version changed, channels number could have changed !
Info:  Autoconf:  We got the NIT, we update the channel names
Info:  Autoconf:  The SDT version changed, channels description have changed
Info:  Autoconf:  We update the channel names
Info:  Autoconf:  We update the channel status
Info:  Autoconf:  Looking through all channels to see if they are ready for streaming
Info:  Autoconf:  We update the channel filters
Info:  Common chan:  Looking through all services to update their filters
Info:  Autoconf:  We update the channel networking
Info:  Common chan:  We open the channel 0 multicast IPv4 socket address 239.100.1.1:1234
Info:  Common chan:  We open the channel 1 multicast IPv4 socket address 239.100.1.2:1234
Info:  Common chan:  We open the channel 2 multicast IPv4 socket address 239.100.1.21:1234
Info:  Common chan:  We open the channel 3 multicast IPv4 socket address 239.100.1.32:1234
Info:  Common chan:  We open the channel 4 multicast IPv4 socket address 239.100.1.33:1234
Info:  Common chan:  We open the channel 5 multicast IPv4 socket address 239.100.1.35:1234
Info:  Common chan:  We open the channel 6 multicast IPv4 socket address 239.100.1.92:1234
Info:  Common chan:  We open the channel 7 multicast IPv4 socket address 239.100.1.93:1234
Info:  Common chan:  We open the channel 8 multicast IPv4 socket address 239.100.1.94:1234
Info:  Main:  Channel "TVP1 HD" down.Card 1
Info:  Main:  Channel "TVP2 HD" down.Card 1
Info:  Main:  Channel "TVP3 Warszawa" down.Card 1
Info:  Main:  Channel "TVP Historia" down.Card 1
Info:  Main:  Channel "TVP Sport HD" down.Card 1
Info:  Main:  Channel "TVP Info" down.Card 1
Info:  Main:  Channel "TVP ABC 2" down.Card 1
Info:  Main:  Channel "TVP Historia 2" down.Card 1
Info:  Main:  Channel "TVP Kultura 2" down.Card 1
Info:  Common chan:  Looking through all services to update their filters
Info:  Autoconf:  We update the channel CAM support
Info:  Autoconf:  Diffusion 9 channels
Info:  Autoconf:  Channel number :   0,   service id 1  name : "TVP1 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.1:1234
Info:  Autoconf:  Channel number :   1,   service id 2  name : "TVP2 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.2:1234
Info:  Autoconf:  Channel number :   2,   service id 21  name : "TVP3 Warszawa"
Info:  Autoconf:    Multicast4 ip : 239.100.1.21:1234
Info:  Autoconf:  Channel number :   3,   service id 32  name : "TVP Historia"
Info:  Autoconf:    Multicast4 ip : 239.100.1.32:1234
Info:  Autoconf:  Channel number :   4,   service id 33  name : "TVP Sport HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.33:1234
Info:  Autoconf:  Channel number :   5,   service id 35  name : "TVP Info"
Info:  Autoconf:    Multicast4 ip : 239.100.1.35:1234
Info:  Autoconf:  Channel number :   6,   service id 92  name : "TVP ABC 2"
Info:  Autoconf:    Multicast4 ip : 239.100.1.92:1234
Info:  Autoconf:  Channel number :   7,   service id 93  name : "TVP Historia 2"
Info:  Autoconf:    Multicast4 ip : 239.100.1.93:1234
Info:  Autoconf:  Channel number :   8,   service id 94  name : "TVP Kultura 2"
Info:  Autoconf:    Multicast4 ip : 239.100.1.94:1234
Info:  Common chan:  Looking through all services to update their filters
Info:  Autoconf:  We update the channel CAM support
Info:  Autoconf:  Diffusion 9 channels
Info:  Autoconf:  Channel number :   0,   service id 1  name : "TVP1 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.1:1234
Info:  Autoconf:  Channel number :   1,   service id 2  name : "TVP2 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.2:1234
Info:  Autoconf:  Channel number :   2,   service id 21  name : "TVP3 Warszawa"
Info:  Autoconf:    Multicast4 ip : 239.100.1.21:1234
Info:  Autoconf:  Channel number :   3,   service id 32  name : "TVP Historia"
Info:  Autoconf:    Multicast4 ip : 239.100.1.32:1234
Info:  Autoconf:  Channel number :   4,   service id 33  name : "TVP Sport HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.33:1234
Info:  Autoconf:  Channel number :   5,   service id 35  name : "TVP Info"
Info:  Autoconf:    Multicast4 ip : 239.100.1.35:1234
Info:  Autoconf:  Channel number :   6,   service id 92  name : "TVP ABC 2"
Info:  Autoconf:    Multicast4 ip : 239.100.1.92:1234
Info:  Autoconf:  Channel number :   7,   service id 93  name : "TVP Historia 2"
Info:  Autoconf:    Multicast4 ip : 239.100.1.93:1234
Info:  Autoconf:  Channel number :   8,   service id 94  name : "TVP Kultura 2"
Info:  Autoconf:    Multicast4 ip : 239.100.1.94:1234
Info:  Main:  Channel "TVP2 HD" back.Card 1
Info:  Main:  Channel "TVP2 HD" down.Card 1
^CERRO:  Main:  Caught signal 2
Killed

When I force mumudvb to ignore those 3 recently added channels it receives all channels correctly.

freq=522000
delivery_system=DVBT
autoconfiguration=full
multicast_iface4=lo
autoconf_ip4=239.100.%card.%sid_lo
autoconf_sid_list_ignore=92 93 94
$ sudo mumudvb -d --card 1 --config /etc/mumudvb/mux3.conf 
MuMuDVB Version 2.1.0
 --- Build information ---
Built without CAM support.
Built without SCAM support.
Built with ATSC support.
Built with support for DVB API Version 5.11.
Built with support for DVB-T2.
---------
Originally based on dvbstream 0.6 by (C) Dave Chapman 2001-2004
Released under the GPL.
Latest version available from http://mumudvb.net/
Project from the cr@ns (http://www.crans.org)
by Brice DUBOST (mumudvb@braice.net)

Info:  Tune:  You will use DVB API version 5 for tuning your card.
Info:  Main:  Autoconfiguration, we activate SAP announces. if you want to disable them see the README.
Info:  Main:  Autoconfiguration, we activate PAT rewriting. if you want to disable it see the README.
Info:  Main:  Autoconfiguration, we activate SDT rewriting. if you want to disable it see the README.
Info:  Main:  ========== End of configuration, MuMuDVB version 2.1.0 is starting ==========
Info:  Main:  Streaming. Freq 522000000.000000
Info:  Tune:  Using DVB card "TurboSight TBS 6281SE DVB-T/T2/C " tuner 0
Info:  Tune:  Tuning Terrestrial to 522000000 Hz, Bandwidth: 8000000
Info:  Tune:  Tuning With DVB-API version 5. delivery system : 3
Info:  Tune:  FE_STATUS:
Info:  Tune:  FE_STATUS:
Info:  Tune:       FE_HAS_SIGNAL : found something above the noise level
Info:  Tune:       FE_HAS_CARRIER : found a DVB signal
Info:  Tune:       FE_HAS_VITERBI : FEC is stable
Info:  Tune:       FE_HAS_SYNC : found sync bytes
Info:  Tune:       FE_HAS_LOCK : everything's working... 
Info:  Tune:  Event:  Frequency: 3
Info:  Tune:  Bit error rate: 15
Info:  Tune:  Signal strength: 46576
Info:  Tune:  SNR: 37392
Info:  Main:  Card 1, tuner 0 tuned
main 0x63dca0
Info:  Common chan:  Looking through all services to update their filters
Info:  Autoconf:  Autoconfiguration is now ready to work for you !
Info:  Autoconf:  The PAT version changed, channels have changed
Info:  Autoconf:  New PAT we force SDT update after all sections seen
WARN:  Autoconf:  Channel 0 SID 1 Force PMT update
WARN:  Autoconf:  Channel 1 SID 2 Force PMT update
WARN:  Autoconf:  Channel 2 SID 21 Force PMT update
WARN:  Autoconf:  Channel 3 SID 32 Force PMT update
WARN:  Autoconf:  Channel 4 SID 33 Force PMT update
WARN:  Autoconf:  Channel 5 SID 35 Force PMT update
WARN:  Autoconf:  Channel 6 SID 92 Force PMT update
WARN:  Autoconf:  Channel 7 SID 93 Force PMT update
WARN:  Autoconf:  Channel 8 SID 94 Force PMT update
Info:  Autoconf:  The NIT version changed, channels number could have changed !
Info:  Autoconf:  We got the NIT, we update the channel names
Info:  Autoconf:  The SDT version changed, channels description have changed
Info:  Autoconf:  We update the channel names
Info:  Autoconf:  We update the channel status
Info:  Autoconf:  Looking through all channels to see if they are ready for streaming
Info:  Autoconf:  We update the channel filters
Info:  Common chan:  Looking through all services to update their filters
Info:  Autoconf:  We update the channel networking
Info:  Common chan:  We open the channel 0 multicast IPv4 socket address 239.100.1.1:1234
Info:  Common chan:  We open the channel 1 multicast IPv4 socket address 239.100.1.2:1234
Info:  Common chan:  We open the channel 2 multicast IPv4 socket address 239.100.1.21:1234
Info:  Common chan:  We open the channel 3 multicast IPv4 socket address 239.100.1.32:1234
Info:  Common chan:  We open the channel 4 multicast IPv4 socket address 239.100.1.33:1234
Info:  Common chan:  We open the channel 5 multicast IPv4 socket address 239.100.1.35:1234
Info:  Main:  Channel "TVP1 HD" down.Card 1
Info:  Main:  Channel "TVP2 HD" down.Card 1
Info:  Main:  Channel "TVP3 Warszawa" down.Card 1
Info:  Main:  Channel "TVP Historia" down.Card 1
Info:  Main:  Channel "TVP Sport HD" down.Card 1
Info:  Main:  Channel "TVP Info" down.Card 1
Info:  Common chan:  Looking through all services to update their filters
Info:  Autoconf:  We update the channel CAM support
Info:  Autoconf:  Diffusion 6 channels
Info:  Autoconf:  Channel number :   0,   service id 1  name : "TVP1 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.1:1234
Info:  Autoconf:  Channel number :   1,   service id 2  name : "TVP2 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.2:1234
Info:  Autoconf:  Channel number :   2,   service id 21  name : "TVP3 Warszawa"
Info:  Autoconf:    Multicast4 ip : 239.100.1.21:1234
Info:  Autoconf:  Channel number :   3,   service id 32  name : "TVP Historia"
Info:  Autoconf:    Multicast4 ip : 239.100.1.32:1234
Info:  Autoconf:  Channel number :   4,   service id 33  name : "TVP Sport HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.33:1234
Info:  Autoconf:  Channel number :   5,   service id 35  name : "TVP Info"
Info:  Autoconf:    Multicast4 ip : 239.100.1.35:1234
Info:  Common chan:  Looking through all services to update their filters
Info:  Autoconf:  We update the channel CAM support
Info:  Autoconf:  Diffusion 6 channels
Info:  Autoconf:  Channel number :   0,   service id 1  name : "TVP1 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.1:1234
Info:  Autoconf:  Channel number :   1,   service id 2  name : "TVP2 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.2:1234
Info:  Autoconf:  Channel number :   2,   service id 21  name : "TVP3 Warszawa"
Info:  Autoconf:    Multicast4 ip : 239.100.1.21:1234
Info:  Autoconf:  Channel number :   3,   service id 32  name : "TVP Historia"
Info:  Autoconf:    Multicast4 ip : 239.100.1.32:1234
Info:  Autoconf:  Channel number :   4,   service id 33  name : "TVP Sport HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.33:1234
Info:  Autoconf:  Channel number :   5,   service id 35  name : "TVP Info"
Info:  Autoconf:    Multicast4 ip : 239.100.1.35:1234
Info:  Common chan:  Looking through all services to update their filters
Info:  Autoconf:  We update the channel CAM support
Info:  Autoconf:  Diffusion 6 channels
Info:  Autoconf:  Channel number :   0,   service id 1  name : "TVP1 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.1:1234
Info:  Autoconf:  Channel number :   1,   service id 2  name : "TVP2 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.2:1234
Info:  Autoconf:  Channel number :   2,   service id 21  name : "TVP3 Warszawa"
Info:  Autoconf:    Multicast4 ip : 239.100.1.21:1234
Info:  Autoconf:  Channel number :   3,   service id 32  name : "TVP Historia"
Info:  Autoconf:    Multicast4 ip : 239.100.1.32:1234
Info:  Autoconf:  Channel number :   4,   service id 33  name : "TVP Sport HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.33:1234
Info:  Autoconf:  Channel number :   5,   service id 35  name : "TVP Info"
Info:  Autoconf:    Multicast4 ip : 239.100.1.35:1234
Info:  Common chan:  Looking through all services to update their filters
Info:  Autoconf:  We update the channel CAM support
Info:  Autoconf:  Diffusion 6 channels
Info:  Autoconf:  Channel number :   0,   service id 1  name : "TVP1 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.1:1234
Info:  Autoconf:  Channel number :   1,   service id 2  name : "TVP2 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.2:1234
Info:  Autoconf:  Channel number :   2,   service id 21  name : "TVP3 Warszawa"
Info:  Autoconf:    Multicast4 ip : 239.100.1.21:1234
Info:  Autoconf:  Channel number :   3,   service id 32  name : "TVP Historia"
Info:  Autoconf:    Multicast4 ip : 239.100.1.32:1234
Info:  Autoconf:  Channel number :   4,   service id 33  name : "TVP Sport HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.33:1234
Info:  Autoconf:  Channel number :   5,   service id 35  name : "TVP Info"
Info:  Autoconf:    Multicast4 ip : 239.100.1.35:1234
Info:  Common chan:  Looking through all services to update their filters
Info:  Autoconf:  We update the channel CAM support
Info:  Autoconf:  Diffusion 6 channels
Info:  Autoconf:  Channel number :   0,   service id 1  name : "TVP1 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.1:1234
Info:  Autoconf:  Channel number :   1,   service id 2  name : "TVP2 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.2:1234
Info:  Autoconf:  Channel number :   2,   service id 21  name : "TVP3 Warszawa"
Info:  Autoconf:    Multicast4 ip : 239.100.1.21:1234
Info:  Autoconf:  Channel number :   3,   service id 32  name : "TVP Historia"
Info:  Autoconf:    Multicast4 ip : 239.100.1.32:1234
Info:  Autoconf:  Channel number :   4,   service id 33  name : "TVP Sport HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.33:1234
Info:  Autoconf:  Channel number :   5,   service id 35  name : "TVP Info"
Info:  Autoconf:    Multicast4 ip : 239.100.1.35:1234
Info:  Common chan:  Looking through all services to update their filters
Info:  Autoconf:  We update the channel CAM support
Info:  Autoconf:  Diffusion 6 channels
Info:  Autoconf:  Channel number :   0,   service id 1  name : "TVP1 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.1:1234
Info:  Autoconf:  Channel number :   1,   service id 2  name : "TVP2 HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.2:1234
Info:  Autoconf:  Channel number :   2,   service id 21  name : "TVP3 Warszawa"
Info:  Autoconf:    Multicast4 ip : 239.100.1.21:1234
Info:  Autoconf:  Channel number :   3,   service id 32  name : "TVP Historia"
Info:  Autoconf:    Multicast4 ip : 239.100.1.32:1234
Info:  Autoconf:  Channel number :   4,   service id 33  name : "TVP Sport HD"
Info:  Autoconf:    Multicast4 ip : 239.100.1.33:1234
Info:  Autoconf:  Channel number :   5,   service id 35  name : "TVP Info"
Info:  Autoconf:    Multicast4 ip : 239.100.1.35:1234
Info:  Main:  Channel "TVP1 HD" back.Card 1
Info:  Main:  Channel "TVP2 HD" back.Card 1
Info:  Main:  Channel "TVP3 Warszawa" back.Card 1
Info:  Main:  Channel "TVP Historia" back.Card 1
Info:  Main:  Channel "TVP Sport HD" back.Card 1
Info:  Main:  Channel "TVP Info" back.Card 1

^CERRO:  Main:  Caught signal 2
ERRO:  Main:  Autoconf error 2
ERRO:  Main:  Autoconf error 2
ERRO:  Main:  Autoconf error 2
ERRO:  Main:  Autoconf error 2
ERRO:  Main:  Autoconf error 2
ERRO:  Main:  Autoconf error 2
ERRO:  Main:  Autoconf error 2
Info:  Main:  End of streaming. We streamed during 0d 0:01:09
Info:  Main:  Caught signal 2 - closing cleanly.
Info:  Main:  ========== MuMuDVB version 2.1.0 is stopping with ExitCode 0 =========

Maybe it's a bug i MPEG-TS parser? I could try putting some debugs in mumudvb code but I should be instructed where to look for the relevant logic.

pszemus commented 1 year ago

I've found an endless while loop here: https://github.com/braice/MuMuDVB/blob/mumudvb2/src/autoconf_pmt.c#L553

In case of channel with SID=92 descriptors_loop_len never reaches 0 nor descriptor_tag is found causing the while loop to run indefinitely. Tomorrow I'll continue my investigation.

pszemus commented 1 year ago

OK, I think I've got it:

We have a char overflow here: https://github.com/braice/MuMuDVB/blob/mumudvb2/src/autoconf_pmt.c#L556

unsigned char descriptor_len = buf[1] + 2;

buf[1] is "254" in my case and after adding "2" descriptor_len becomes "0" instead of "256".

I'll send a PR in a moment.