[mythtv-commits] Ticket #3352: Frequent mythbackend crashes when recording UK DVB-T channel "five", presumably bad/unsupported stream data. [+tentative patch]

MythTV mythtv at cvs.mythtv.org
Wed Apr 25 21:54:48 UTC 2007


#3352: Frequent mythbackend crashes when recording UK DVB-T channel "five",
presumably bad/unsupported stream data. [+tentative patch]
-----------------------+----------------------------------------------------
 Reporter:  anonymous  |       Owner:  ijr       
     Type:  defect     |      Status:  new       
 Priority:  minor      |   Milestone:  unknown   
Component:  mythtv     |     Version:  0.20-fixes
 Severity:  high       |  
-----------------------+----------------------------------------------------
 This has been bugging me for a while so I decided to track it down.
 Basically, when recording shows on the UK "five" and "five US",
 mythbackend would segfault frequently. Recording an hour-long show without
 a crash had about 20% success rate. The phenomenon has been reported in
 the mailing lists, so I figured it wasn't dodgy hardware or setup. (
 http://mythtv.org/pipermail/mythtv-users/2007-April/176406.html ) I'm
 running an i586 0.20-fixes rpm build for openSUSE 10.2, available at
 packman.links2linux.org.

 Now, I'm a programmer, so the logical thing was to try and fix it. I've
 created a patch, but it's more of a "fix the symptom" than a "fix the
 cause" patch, and although it's certainly got rid of those crashes, I'd
 appreciate if someone who knows the codebase (I'm a MythTV n00b) could
 take a look at this. Here's my write-up so far:

 I ran mythbackend in gdb, and it crashed (repeatably) in the DVB recording
 thread (surprise!), specifically, at libmythtv's mpegtables.h, function
 ProgramAssociationTable::ProgramPID(i), where i was some large number.
 (the exact number varied, I saw pretty much anything in the range of
 60000-100000) Caller was DVBRecorder::AdjustFilters(), line
 dvbrecorder.cpp:543. The only way i can be that big is if
 _input_pat->ProgramCount() (line 541) returns something really high.

 Except that, as far as I can tell, ProgramCount() should only return
 something in the range of about 0-122:
 (/branches/release-0-20-fixes/mythtv/libs/libmythtv/mpeg/mpegtables.h)
 {{{
 405         uint ProgramCount(void) const
 406             { return (SectionLength()-PSIP_OFFSET-2)>>2; }
 }}}
 Except of course if SectionLength() is less than PSIP_OFFSET + 2, where a
 negative number gets cast to a uint, and bang, you're dead.

 So my 'dumb' fix (see patch) is to check for that condition and return 0
 instead of some large number.

 I can only speculate the cause for this happening in the first place (why
 would SectionLength() be so short?), as I'm not familiar with the data
 structures in the DVB stream. Either the multiplex with said channels
 produces bad data once in a while, MythTV doesn't handle some valid stream
 data correctly, or something in the chain from Antenna to MythTV (tuner,
 driver, kernel?) is mangling the data. Either way, it shouldn't crash
 Myth, so the validity should probably be checked somewhere. Where and how,
 I do not know, this is where the experts come in, I hope. :)

 Now, I would imagine you guys need some way to repro the problem locally,
 you'll need the data that triggers it. Any help in obtaining said data
 would be much appreciated. Feel free to send me a debugging patch that
 dumps whatever data to file when that condition is hit. Whatever helps,
 really.

-- 
Ticket URL: <http://svn.mythtv.org/trac/ticket/3352>
MythTV <http://svn.mythtv.org/trac>
MythTV


More information about the mythtv-commits mailing list