Opened 8 years ago

Closed 6 years ago

#12856 closed Bug Report - Crash (Won't Fix)

mythbackend seg fault livetv via Kodi using Vbox Tuner

Reported by: mike.bibbings@… Owned by:
Priority: minor Milestone: 0.28.2
Component: MythTV - General Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

mythbackend seg faults when changing LiveTV channels using Kodi pvr.mythtv addon when using Vbox network tuner. The Vbox tuner works correctly when using mythfrontend i.e. I can change channels in LiveTV at will. Note that on the same mythbackend when using a USB DVB-T/T2 (Astrometa) Kodi channel changing on LiveTV works correctly using the same pvr.mythtv addon.

mythbackend version MythTV Version : v29-pre-138-geaf81bc-dirty MythTV Branch : master Network Protocol : 91 Library API : 29.20160714-1 QT Version : 5.5.1 Options compiled in:

linux profile use_hidesyms using_alsa using_oss using_pulse using_pulseoutput using_backend using_bindings_perl using_bindings_python using_bindings_php using_crystalhd using_dvb using_firewire using_frontend using_hdhomerun using_vbox using_ceton using_hdpvr using_ivtv using_joystick_menu using_libcec using_libcrypto using_libdns_sd using_libfftw3 using_libxml2 using_lirc using_mheg using_opengl using_opengl_video using_opengl_themepainter using_qtwebkit using_qtscript using_qtdbus using_taglib using_v4l2 using_x11 using_xrandr using_xv using_profiletype using_bindings_perl using_bindings_python using_bindings_php using_freetype2 using_mythtranscode using_opengl using_vaapi using_vdpau using_ffmpeg_threads using_mheg using_libass using_libxml2

gdb backtrace and mythbackend log attached.

Attachments (9)

gdb.txt (74.6 KB) - added by mike.bibbings@… 8 years ago.
gdb backtrace
mythbackend.20160813164419.27149.log.tar.gz (205.8 KB) - added by mike.bibbings@… 8 years ago.
mythbackend log
gdb.2.txt (49.0 KB) - added by mike.bibbings@… 8 years ago.
gdb backtrace
mythbackend.20160829114407.10104.log (272.9 KB) - added by mike.bibbings@… 8 years ago.
mythbackend log
mythfrontend_version (971 bytes) - added by mike.bibbings@… 8 years ago.
mythfrontend version
mythbackend_version (971 bytes) - added by mike.bibbings@… 8 years ago.
mythbackend version
mythbackend-vbox12.log (709.0 KB) - added by mike.bibbings@… 8 years ago.
mythbackend-vbox12.log
myth_additional_temp_logging.patch (3.1 KB) - added by mike.bibbings@… 8 years ago.
myth_additional_temp_logging.patch
mythbackend-vbox14.log.tar.gz (1.6 MB) - added by mike.bibbings@… 8 years ago.
mythbackend-vbox14.log.tar.gz

Change History (27)

Changed 8 years ago by mike.bibbings@…

Attachment: gdb.txt added

gdb backtrace

Changed 8 years ago by mike.bibbings@…

mythbackend log

comment:1 Changed 8 years ago by charles.bovy@…

Looks similar to #12773

comment:2 in reply to:  1 Changed 8 years ago by mike.bibbings@…

Replying to charles.bovy@…:

Looks similar to #12773

Yes, although in my case it is almost every other channel change following mythbackend restart from the seg fault. From some investigations it seems that SpawnLive? has issues.

I have a test system available and can do some more investigations if someone can give me some hints on what to do.

Mike

comment:3 Changed 8 years ago by Stuart Auchterlonie

Milestone: unknown0.28.1

comment:4 Changed 8 years ago by paulh

Unable to reproduce this since I can't get the Kodi plugin to work (failing with a protocol version error)

comment:5 in reply to:  4 Changed 8 years ago by mike.bibbings@…

Replying to paulh:

Unable to reproduce this since I can't get the Kodi plugin to work (failing with a protocol version error)

I am guessing you used Kodi 16.1 and associated pvr.mythtv plugin which does not currently support mythtv master builds.

My fault in not explaining my Kodi configuration, which was Kodi and pvr.mythtv build from source using Kodi master and pvr.mythtv doityourself branch (janbar github).

I have just retested using MythTV Version : v0.28-50-gd9182ff MythTV Branch : fixes/0.28 from the ppa, with Kodi 16.1 and associated pvr.mythtv, same seq fault problem exists.

For Ubuntu Kodi 16.1 install:

sudo apt-get install software-properties-common sudo add-apt-repository ppa:team-xbmc/ppa sudo apt-get update sudo apt-get install kodi kodi-pvr-mythtv

Mike

comment:6 Changed 8 years ago by mike.bibbings@…

I have managed to get the seg fault consistently without using Kodi, just mythfrontend. I setup a new install using current 0.28/Fixes from ppa with a single vbox tuner configured. Note The seg fault can be created on 0.29 built from source in the same way as below.

Steps to reproduce the problem: At mythfrontend main screen select Programme Guide

Press Menu key and select Watch This Channel, channel tunes and plays OK

Exit from LiveTV, which puts you back in Programme Guide

Press Down Arrow to move to another channel, then Menu key and Select Watch This Channel, crash happens at this point.

Attachments gdb.txt backtrace mythbackend.log mythfrontend version mythbackend version

Changed 8 years ago by mike.bibbings@…

Attachment: gdb.2.txt added

gdb backtrace

Changed 8 years ago by mike.bibbings@…

mythbackend log

Changed 8 years ago by mike.bibbings@…

Attachment: mythfrontend_version added

mythfrontend version

Changed 8 years ago by mike.bibbings@…

Attachment: mythbackend_version added

mythbackend version

comment:7 Changed 8 years ago by Stuart Auchterlonie

The backtrace here is looking like what we are seeing on #12773

comment:8 Changed 8 years ago by paulh

Made a little progress on this.

I can randomly reproduce it now using a VBox as source by starting and stopping live TV and switching channels a few times it will eventually segfault.

Using gdb to look at a few things the only strange thing I see is m_buffer instead of being filled with the stream data it contains a web page showing a "500 Internal Error". So for whatever reason the VBox is failing to start streaming and that is somehow causing the segfault.

I suspect it has something to do with the QEventLoop in HTTPReader::DownloadStream?(const QUrl url) exiting quicker than when a stream succeeds possibly with the order of the SIGNALS being called in a different order but I still can't see how that leads to the segfault in the BT. Open to suggestions :)

comment:9 in reply to:  8 Changed 8 years ago by mike.bibbings@…

Replying to paulh:

Made a little progress on this.

I can randomly reproduce it now using a VBox as source by starting and stopping live TV and switching channels a few times it will eventually segfault.

Using gdb to look at a few things the only strange thing I see is m_buffer instead of being filled with the stream data it contains a web page showing a "500 Internal Error". So for whatever reason the VBox is failing to start streaming and that is somehow causing the segfault.

I suspect it has something to do with the QEventLoop in HTTPReader::DownloadStream?(const QUrl url) exiting quicker than when a stream succeeds possibly with the order of the SIGNALS being called in a different order but I still can't see how that leads to the segfault in the BT. Open to suggestions :)

The seg fault happens like clockwork on my system (either with mythfrontend or with Kodi and pvr.mythtv addon).

I can patch a source build if you have some extra logging statements you would like included to narrow down the problem. Just let me have details of what and where. I currently have a source build of 0.28 fixes, but if you want me to patch 0.29 I can do that.

Mike

comment:10 Changed 8 years ago by mike.bibbings@…

Done some more digging around in current master and now have identified what is happening. mythsingledownload is being triggered on a different channel in the middle of tuning to a new channel. see near end of mythbackend-vbox12.log. I temporarily added some more logging during my investigations, patch (its ugly and only for my own use) is included for completeness myth_additional_temp_logging.patch. The original backtraces did not show everything as logging stopped at the seg fault.

Changed 8 years ago by mike.bibbings@…

Attachment: mythbackend-vbox12.log added

mythbackend-vbox12.log

Changed 8 years ago by mike.bibbings@…

myth_additional_temp_logging.patch

comment:11 Changed 8 years ago by paulh

Thanks Mike. Just to make sure we are looking in the right area can you patch the backend and just put

return false;

right at the top of bool IsHLSPlaylist(void) here:- https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythtv/iptvtuningdata.h#L221 so we avoid doing the extra download to check for an HLS playlist (we know in the case of the VBox we are not dealing with an HLS playlist so we can avoid doing the check).

Changed 8 years ago by mike.bibbings@…

mythbackend-vbox14.log.tar.gz

comment:12 in reply to:  11 Changed 8 years ago by mike.bbbings@…

Replying to paulh:

Thanks Mike. Just to make sure we are looking in the right area can you patch the backend and just put

return false;

right at the top of bool IsHLSPlaylist(void) here:- https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythtv/iptvtuningdata.h#L221 so we avoid doing the extra download to check for an HLS playlist (we know in the case of the VBox we are not dealing with an HLS playlist so we can avoid doing the check).

Did a complete rebuild with just the above change (no extra logging patch), no more seg faults and Kodi with pvr.mythtv now works. I have attached mythbackend-vbox14.log for reference

Mike

comment:13 Changed 7 years ago by charles.bovy@…

Comment:11 is also work-around for #12773

comment:14 Changed 7 years ago by perkins1724@…

I have very similar symptoms to those described by Mike when using an IPTV Tuner pointing to a mumudvb rebroadcast (i'm using it in http unicast mode).

However the fix at Comment:11 made no difference for me despite the similar symptoms.

I always get the segfault on second entry into LiveTV. Comparing logs of first entry to LiveTV against second entry to LiveTV I found main differences were:

1) RingBufferReady? flag seems to be already set second time around even though the RingBuffer? was closed when exiting LiveTV from first entry.

2) m_stream_data is still set on second LiveTV entry which triggers SetStreamData?(m_stream_data) at https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythtv/recorders/iptvchannel.cpp#L52

For (1) I added ClearFlags?(kFlagRingBufferReady, FILE, LINE); at line 3660 of tv_rec.cpp (https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythtv/tv_rec.cpp#L3660) which got rid of the RingBufferReady? flag at the second entry to LiveTV - however it made no difference to anything so I presume either dead end or intended behaviour.

For (2) I couldn't work out how to unset m_stream_data at the end of void IPTVChannel::Close(void) https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythtv/recorders/iptvchannel.cpp#L86 so I just commented out lines 52 and 53 of iptvchannel.cpp so the check never occurs. This fixed the crash for me and has been working for a couple of days now. But I presume is only masking the symptom rather than the proper fix.

comment:15 Changed 7 years ago by mike.bibbings@…

Possible solution to original problem:

Based on my understanding (which is limited) of HLSPLaylists within current Mythtv, the URL should end with either .m3u8 or .m3u.

I have modified IsHLSPlaylist in file iptvtuningdata.h to return false unless URL ends in either .m3u8 or .m3u in which case MythSingleDownload? will be triggered. VBox channel URLs (in iptv_channel table) do not end with either .m3u8 or .m3u.

This has been tested on mythtv master

diff --git a/mythtv/libs/libmythtv/iptvtuningdata.h b/mythtv/libs/libmythtv/iptvtuningdata.h
index c5a3c2e..c86b14d 100644
--- a/mythtv/libs/libmythtv/iptvtuningdata.h
+++ b/mythtv/libs/libmythtv/iptvtuningdata.h
@@ -220,13 +220,29 @@ class MTV_PUBLIC IPTVTuningData
   protected:
     bool IsHLSPlaylist(void)
     {
-        if (!qApp)
+    if (!qApp)
         {
             LOG(VB_GENERAL, LOG_ERR, QString("IsHLSPlaylist - No QApplication!!"));
             return false;
         }
 
         QString url = m_data_url.toString();
+        
+        // check url is valid for a playlist before downloading (see trac ticket #12856)
+        if(url.endsWith(".m3u8", Qt::CaseInsensitive) ||
+           url.endsWith(".m3u", Qt::CaseInsensitive))
+        {
+            LOG(VB_RECORD, LOG_INFO, QString("IsHLSPlaylist url ends with either .m3u8 or .m3u %1")
+                           .arg(url));
+        }
+        else
+        {
+            // not a valid playlist so just return false
+            LOG(VB_RECORD, LOG_INFO, QString("IsHLSPlaylist url does not end with either .m3u8 or .m3u %1")
+                           .arg(url));
+            return false;    
+        }
+        
         QByteArray buffer;
 
         MythSingleDownload downloader;

comment:16 Changed 7 years ago by Stuart Auchterlonie

Milestone: 0.28.10.28.2

Moving remaining open 0.28.1 tickets to 0.28.2

comment:17 Changed 7 years ago by perkins1724@…

Just to update on my comment:14 above. My patch worked for me if only livetv was in progress but I still get crashes if I have existing recordings in progress and try to enter livetv. However at this point it seems probable that my issues were unrelated to Mike's despite the similar symptoms so I will keep my further comments away from this ticket.

comment:18 Changed 6 years ago by Stuart Auchterlonie

Resolution: Won't Fix
Status: newclosed

Closing any remaining tickets for 0.28, if the issue persists, feel free to reopen and align to v29 or master

Note: See TracTickets for help on using tickets.