View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 6 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Wed Feb 23, 2005 6:10 am 
Offline
Joined: Mon May 10, 2004 8:08 pm
Posts: 1891
Location: Adelaide, Australia
If the backend segfaults, will there be anything in the backend log file? I don't think so, because a number of times my backend has gone missing and when I check the log file there is no indication of an error.

At work, we run linux executables from a script that checks if the executable dumped a core. If a core was dumped, it uses gdb to do a backtrace. The output of this backtrace then ends up in the log file for the task (since all of the output from the script goes into a log file). This is often enough info for the programmer to realise the error of his ways and fix the bug so that it doesn't occur again (sometimes, perhaps often, problems are more devious than this but its surprising how often it helps).

1. Do you think that this sort of thing would be useful for helping people search for solutions to the backend crashing?

It may be a known problem described on the myth-dev mailing lists, but if all the user knows is that the backend went poof :shock:, they are not going to recognise the fix. Myth would probably have to be compiled with the -g flag so that symbolic information was retained.

2. Are there any drawbacks to running stuff compiled with the -g flag?

At work, performance is not the key, correctness is, so any -g overhead (if there is any, I don't know) is gracefully accepted. I for one think that this would be useful and it would be easy to include with the knoppmyth distribution. If anyone else thinks this is a good idea, please add your support and I will post the commands we use at work to detect the core and backtrace it so that cesman (if he thinks it is wise) might see fit to include it.

3. On a similar note, should we have a backtrace log for the frontend as well?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 23, 2005 1:15 pm 
Offline
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location: Fontana, Ca
1. It wouldn't help the average users. It would help the community as a whole if this information was provided to the MythTV devs so they can fix it. This is especially true if folks are running CVS before a release.

2. The debs are compiled with -g. However, I have removed the mythtb-debug because there where HUGE.

3. Yes.

Just this morning I posted an email lto mythtv-dev asking how I can make MythTV more stable. It seems the best way to test test test CVS before a release. I'll try and keep a closer eye on the dev mailing list so I can produce CVS debs before a release. To those that watch the list or if you're an active developer and know when a release is plan, please let me know if you don't see me post something. So Greg, your post is just in time. Perhaps you can do a write up and and or on the wiki that describes how to get use your script(s) and how to submit it to the MythTV devs?

_________________
cesman

When the source is open, the possibilities are endless!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 23, 2005 4:54 pm 
Offline
Joined: Mon May 10, 2004 8:08 pm
Posts: 1891
Location: Adelaide, Australia
OK I'll try getting it going on my box and then post on the wiki. Time is a bit of a problem, but I'll see how I go.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 5:22 am 
Offline
Joined: Mon May 10, 2004 8:08 pm
Posts: 1891
Location: Adelaide, Australia
I finally got around to having a look at this. I'm posting what I did here rather than on the wiki in the hope that it will be included in the next alpha and then this thread can disappear into obscurity and everyone's KnoppMyth box will produce useful logs if (or when) things go wrong.

To get core dumps from the backend, I created a script /usr/bin/mythbackend.backtrace that looks like this:
Code:
#!/bin/bash

OUTFILE=/var/log/mythtv/mythbackend.log
cd `dirname $OUTFILE`
EXENAME=`echo $0 | cut -d "." -f 1`

echo "


================================================================" >> $OUTFILE
echo "`date` Running $EXENAME $*" >> $OUTFILE
echo "In Directory `pwd`" >> $OUTFILE
ulimit -c 1000000

$EXENAME $* >> $OUTFILE 2>&1

if [ -e core ] ; then
  echo "`date` : Found core file, doing backtrace:" >> $OUTFILE
  echo backtrace > backtrace
  gdb -batch -x backtrace $EXENAME core >> $OUTFILE 2>&1
  rm -f core
fi

I then changed the script that starts the backend (/etc/init.d/mythtv-backend) so that it launches the script instead of the directly launching the backend by changing the line as shown below (note the addition of .backtrace):
Quote:
start-stop-daemon --start --pidfile $RUNDIR/$NAME.pid \
--chuid $USER --nicelevel $NICE --exec $DAEMON.backtrace -- $ARGS
Then, to test it I created a mickey mouse program x.c that crashed with a core dump as shown below:
Code:
#include <unistd.h>
#include <stdio.h>
another_function (int an_arg){int * a = 0; sleep (2);*a = 10;}
a_function (char * a) {another_function (2345);}
main () {a_function ("hello");}

Compiled with "cc -g x.c" and then replaced /usr/bin/mythbackend with the a.out that was created (after making a backup of course).
Then I stopped the backend using
Code:
/etc/init.d/mythtv-backend stop

and started it again using
Code:
/etc/init.d/mythtv-backend start

After the backend crashes, the log file looks like this showing all of the functions and arguments on the stack at the point at which it crashed:
Code:
2005-02-25 20:33:46 Changing from None to RecordingOnly
2005-02-25 20:33:46 DVB#0 Recorder: Card opened successfully.
Audiostream: Layer: 2  BRate: 256 kb/s  Freq: 48.0 kHz
Videostream: ASPECT: 16:9  Size = 720x576  FRate: 25 fps  BRate: 15.00 Mbit/s



================================================================
Fri Feb 25 21:33:39 PST 2005 Running /usr/bin/mythbackend --daemon --logfile /var/log/mythtv/mythbackend.log --pidfile /var/run/mythtv/mythbackend.pid
In Directory /var/log/mythtv
Fri Feb 25 21:33:41 PST 2005 : Found core file, doing backtrace:
Core was generated by `/usr/bin/mythbackend --daemon --logfile /var/log/mythtv/mythbackend.log --pidfi'.
Program terminated with signal 11, Segmentation fault.

warning: current_sos: Can't read pathname for load map: Input/output error

#0  0x08048379 in another_function (an_arg=2345) at x.c:8
8    *a = 10;
#0  0x08048379 in another_function (an_arg=2345) at x.c:8
#1  0x08048394 in a_function (a=0x80484c8 "hello") at x.c:13
#2  0x080483b6 in main () at x.c:18


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 4:32 pm 
Offline
Joined: Mon May 10, 2004 8:08 pm
Posts: 1891
Location: Adelaide, Australia
cesman wrote:
1. It wouldn't help the average users.
It might help some users realise when a problem they are experiencing has been found by others, and if using CVS would help them. I guess it depends on your definition of "average".


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 25, 2005 4:49 pm 
Offline
Site Admin
Joined: Fri Sep 19, 2003 6:37 pm
Posts: 2659
Location: Whittier, Ca
You sir are clearly above average! :)


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: Bing [Bot] and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu