TSWriter deadlock potential fix.

Discussion in 'Area 51 - Testing Area' started by DJBlu, December 21, 2012.

  1. DJBlu

    DJBlu Portal Pro

    Joined:
    August 14, 2007
    Messages:
    1,670
    Likes Received:
    789
    Location:
    Llanelli
    Ratings:
    +894 / 1
    Home Country:
    United Kingdom United Kingdom
    Hi,

    This thread has been opened so we can get to the root of the problem so we can introduce the fix.

    The following TSWriter is for 1.3.0 Beta.

    To use and test.

    Stop TV Server.
    Make a backup of your original TSWriter.ax
    Download the attached TSWriter.zip and extract the file to [%Program Files%]/Team MediaPortal/TV Server/
    Start the TV Server.
    Wait till/if the error occurs again.
    Upload your TV.log and TSWriter.log to this thread.

    The more logs we get the better.

    TSWriter.ax

    v1 Initial Test [FILE DELETED: superseded]
    v2 Loop catcher in EPG Decoder sub. [FILE DELETED: superseded]
    v3 Additional locks to make the TSWriter thread safe. [FILE DELETED: superseded]
    v4 Edited out commented line in EPG Decoder which was setting m_bParseEPG=false. Changed the CRC32 value storage from int to DWORD. Checked all locks to ensure they should be there. [FILE DELETED: superseded]
    v5 Diskrecorder wasn't updating continuity counter on a stream if it became encrypted/corrupt. [FILE DELETED: superseded]
    v6 Removed v5 changes, removed an autolock in the filter interface. [FILE DELETED: superseded]
    v7 Removed cascaded Autolock in GetTSChannel from TSWriter. [FILE DELETED: superseded]
    v8 Added Critical Section lock to Audio Video Analyzer. [FILE DELETED: superseded]
    v9 Added Critical Section lock to PMT grabber.
    v10 Removed 2 Autolocks from AddChannel/RemoveChannel from TSChannel
    v11 Added further locks
    v12 Added EPG grabber abort when all channels are deleted.
    MPFileWriter.ax
    v13 Added extra logging in EPG Decoder to trap deadlock.

    v1 Removed Autolock from filter interface. [FILE DELETED: superseded]
    v2 Removed potential Autolock cascade

    EDIT: Patched installer files for MP 1.5.0 Pre-release are here - https://forum.team-mediaportal.com/...ock-potential-fix.114898/page-24#post-1027981

    EDIT: Patch files for MP 1.5.0 Final are here - https://forum.team-mediaportal.com/...ock-potential-fix.114898/page-26#post-1030415


     

    Attached Files:

    Last edited by a moderator: October 2, 2013
    • Like Like x 7
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. tourettes
    • Team MediaPortal

    tourettes Retired Team Member

    Joined:
    January 7, 2005
    Messages:
    17,301
    Likes Received:
    4,595
    Ratings:
    +4,810 / 3
    Could we have the patch / branch as well for the code review?
     
  4. DJBlu

    DJBlu Portal Pro

    Joined:
    August 14, 2007
    Messages:
    1,670
    Likes Received:
    789
    Location:
    Llanelli
    Ratings:
    +894 / 1
    Home Country:
    United Kingdom United Kingdom
    Yer. I am setting up the branch on github as I type.
     
    • Like Like x 3
  5. ramu

    ramu Portal Pro

    Joined:
    July 15, 2008
    Messages:
    189
    Likes Received:
    6
    Ratings:
    +10 / 2
    Hi,

    here is the first result and a little bit history to that thread:

    1. I changed from normal EPG to webEPG and had no crashes afterwarts
    2. Some days ago I updated to 1.3.0 beta, this version also runs over days!
    3. There I had no problems with crashes and also normal EPG worked well
    4. My only BIG problem was that dvb-S card stopped scanning after some channels and reported "nothing found", just discussing with mm
    5. Today I changed tswriter.ax as described before
    6. Had no problems scanning dvb-s, everything works well for some minutes
    7. After about 5-10 min tvserver crashes without visible error messages and vanishes from MS task manager
    8. So, i'll attach the logfiles and rechanged tswriter.ax to the orignial file from 1.3.0 beta

    So I hope MP will stay stable now...

    ramu
     
  6. DJBlu

    DJBlu Portal Pro

    Joined:
    August 14, 2007
    Messages:
    1,670
    Likes Received:
    789
    Location:
    Llanelli
    Ratings:
    +894 / 1
    Home Country:
    United Kingdom United Kingdom
    Hi,

    Thanks for the logs.

    I have uploaded a v2 of the TSWriter. If you could give it a try and report back I would appreciate it thanks.
     
  7. ramu

    ramu Portal Pro

    Joined:
    July 15, 2008
    Messages:
    189
    Likes Received:
    6
    Ratings:
    +10 / 2
    Ok, here are the logs. Tvserver crashed after second try to watch dvb-s....

    By the way first try didn't run so I changed twice th etswriter.ax versions....

    Last log entries are Your version.
     
  8. stevie77

    stevie77 Portal Member

    Joined:
    June 21, 2007
    Messages:
    24
    Likes Received:
    8
    Ratings:
    +8 / 0
    Home Country:
    Austria Austria
    Hi DJBlu,
    I think i've already tracked down the problem. Tswriter in general is not threadsafe while accessing subchannels. Currently only the selection of subchannels ("GetTschannel") is protected. But this way subchannels may get destroyed while other threads are still acccessing it or before callbacks get resetted.

    I've moved the critical section protection ("CAutoLock lock(&m_Lock)") from GetTsChannel to every interface function that uses it and haven't got any deadlocks using my personal version for months now.

    I may provide source code and a compiled version of tswriter if someone likes to test.
     
    Last edited: December 22, 2012
    • Like Like x 4
  9. DJBlu

    DJBlu Portal Pro

    Joined:
    August 14, 2007
    Messages:
    1,670
    Likes Received:
    789
    Location:
    Llanelli
    Ratings:
    +894 / 1
    Home Country:
    United Kingdom United Kingdom
    Can you upload your TSWriter.cpp here so I can take a look and create the fix.

    Thanks.
     
    • Like Like x 1
  10. stevie77

    stevie77 Portal Member

    Joined:
    June 21, 2007
    Messages:
    24
    Likes Received:
    8
    Ratings:
    +8 / 0
    Home Country:
    Austria Austria
    Here you are ...
     

    Attached Files:

    • Like Like x 1
  11. DJBlu

    DJBlu Portal Pro

    Joined:
    August 14, 2007
    Messages:
    1,670
    Likes Received:
    789
    Location:
    Llanelli
    Ratings:
    +894 / 1
    Home Country:
    United Kingdom United Kingdom
    Thanks

    Uploaded a new file to first post if everyone can test please.

    Changes committed and pushed to git.
     
    Last edited: December 22, 2012
    • Like Like x 2
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!