LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-29-2010, 05:42 AM   #1
GTrax
Member
 
Registered: Oct 2005
Location: UK
Distribution: Mint
Posts: 258

Rep: Reputation: 37
Question How to Trap a Crashing App ??


Hi LQ Folk

I would like to learn the right way, or some neat technique, to discover why a compiled-from-source application just unaccountably quits. I am looking for approach advice, since it it easy enough to discover that the pre-compiled version from Ubuntu does work just fine.
My motivation is to explore, and maybe try to modify it a little for myself.

At my level of programming expertise, I have often used the "sh configure, make, make install" route; and sometimes made small changes to the code eg. changing a window size and similar. C and C++ tutorials teach the main rules, but I am no expert at classes, structures or obscure expression tricks.

The application is a QT type called "qantenna", used for electromagnetic simulation of antennas. The source I downloaded from SourceForge. Although a KDE application, the repository version seems to run just fine on my Ubuntu 9.10 Karmic (soon to become Lucid), on its Gnome desktop.

The compiled version behavior is that the main window opens and runs OK, with the GUI view operating with fully alterable views. As soon as a valid antenna file is loaded, the whole application instantly quits.

How does one deal with an application that gives no chance to catch it doing things wrong?
 
Old 08-29-2010, 05:52 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
You could start the application from a terminal
For more debugging you can use strace
 
Old 08-29-2010, 06:00 AM   #3
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Greetingz!

Sounds like your application is having a "Segmentation Fault", which means there should be a "core" file somewhere in the directory the application was started in (or perhaps your home directory).
You can attempt to analyze the "core" file (not an area of my expertise, I'm afraid), or you can try to run your application within a debugger (something I've had to restore to from time to time).

The GNU Debugger "gdb" helps out tremendously in this regards. There are several good guides to using this debugger.

Note that you may have to recompile the application in order to use the debugger.

On a side note, I would check the config.log and output during compilation for any grevious errors. There's probably a library problem somewhere...
 
1 members found this post helpful.
Old 08-29-2010, 01:15 PM   #4
Elv13
Member
 
Registered: Apr 2006
Location: Montreal,Quebec
Distribution: Gentoo
Posts: 825

Rep: Reputation: 129Reputation: 129
The core files are disabled by default in most distribution, you have to turn it on, Google can help on that. About gdb, just open the application in gdb, the write run then, once crashed "backtrace". If you compiled the program with debug support, it will print the reference in the code where the application crashed.
 
Old 08-29-2010, 06:05 PM   #5
GTrax
Member
 
Registered: Oct 2005
Location: UK
Distribution: Mint
Posts: 258

Original Poster
Rep: Reputation: 37
Quote:
Originally Posted by repo View Post
You could start the application from a terminal
For more debugging you can use strace
Thanks much for the suggestion. The output from strace is huge! Unfortunately, it also significantly modifies the displayed behavior.
Even so - I can see where strace can be useful.
 
Old 08-29-2010, 06:48 PM   #6
GTrax
Member
 
Registered: Oct 2005
Location: UK
Distribution: Mint
Posts: 258

Original Poster
Rep: Reputation: 37
Quote:
Originally Posted by xeleema View Post
On a side note, I would check the config.log and output during compilation for any grevious errors. There's probably a library problem somewhere...
Thanks much xeleema
You could be right about the library.
My first try into checking this one out was to simply set it off in a terminal, instead of using a desktop icon launcher. First I cd to the <path>/bin where the executable got made. The result is as follows..
Code:
<path>/bin$ ./qantenna
(QUrl("file:///usr/local/share/doc/qantenna/examples") )  
NEC output parser - The file does not exist (Yes - we know! The app has to make it first!)

ASSERT failure in QList<T>::at: "index out of range", file /usr/include/qt4/QtCore/qlist.h, line 395
Aborted
<path>/bin$
QList<T> turns out to be a Qt Class Reference http://doc.trolltech.com/latest/qlist.html
Er.. this looks kinda advanced! :O
Code:
    // From qlist.h
393 template <typename T>
394 inline const T &QList<T>::at(int i) const
395 { Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::at", "index out of range");
396 return reinterpret_cast<Node *>(p.at(i))->t(); }
I guess somewhere in the source code, QList<T> was used, possibly in unwise manner. This does not mean I know what it is, or what to do with it when I find it. This is one of those situations where some major experiences learning GNU Debug and Classes has first to be done. Best way is to get into trying to do it - I think..
 
Old 08-30-2010, 02:19 PM   #7
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Quote:
Originally Posted by GTrax View Post
Er.. this looks kinda advanced! :O
Code:
    // From qlist.h
393 template <typename T>
394 inline const T &QList<T>::at(int i) const
395 { Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::at", "index out of range");
396 return reinterpret_cast<Node *>(p.at(i))->t(); }
I'll let you in on a little coding secret; It's (almost) never the line number the program says it is. Usually it's the line right before the line number it reports.

In this case, however, I will definetly have to agree with you; this is quite a bit out of my range (pardon the pun).
I'm half tempted to ask you; Is there a newer version of the source code for what you're compiling out there somewhere?
Perhaps you could recompile and double-check for any errors?

Maybe a kind moderator can move your thread over to Programming?
(I'm not sure if you, as the Original Poster, could move the thread...I've never started a thread here before...)

Good luck!

Last edited by xeleema; 08-30-2010 at 02:21 PM.
 
1 members found this post helpful.
Old 08-30-2010, 08:01 PM   #8
GTrax
Member
 
Registered: Oct 2005
Location: UK
Distribution: Mint
Posts: 258

Original Poster
Rep: Reputation: 37
Quote:
Originally Posted by xeleema View Post
Maybe a kind moderator can move your thread over to Programming?
Good luck!
Thats OK - its in the right place. The software issue is now with the application creator. I can learn programming in another place.

I have managed to find the originator of the code, and he has had this reported before, though not (so far) been able to reproduce it. We now have some help!

It would seem that the way to deal with programs that suddenly crash is to repeatedly crash them while gathering as many clues as possible using strace, and monitoring the tail of dmesg. Compiling it with debugging symbols option, and using breakpoints at the suspect places will eventually reveal it.

Thanks much for your help.
 
Old 08-31-2010, 05:28 AM   #9
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Question tail dmesg?

Quote:
Originally Posted by GTrax View Post
...monitoring the tail of dmesg...
Wait, what? Tailing dmesg? I'm curious, how do you do this?
(A quick copy/paste of the command you use would be most helpful)
 
Old 08-31-2010, 06:40 AM   #10
10110111
Member
 
Registered: Jun 2008
Location: St.-Petersburg, Russia
Distribution: (B)LFS, Ubuntu, SliTaz
Posts: 403

Rep: Reputation: 51
Quote:
Tailing dmesg? I'm curious, how do you do this?
Code:
dmesg|tail
? Or, maybe even
Code:
watch "dmesg|tail"
?
 
Old 08-31-2010, 09:00 AM   #11
GTrax
Member
 
Registered: Oct 2005
Location: UK
Distribution: Mint
Posts: 258

Original Poster
Rep: Reputation: 37
Quote:
Originally Posted by xeleema View Post
Wait, what? Tailing dmesg? I'm curious, how do you do this?
(A quick copy/paste of the command you use would be most helpful)
I have used it before to monitor the activity of a program, but only as a copied technique. I was able to see the last 10 lines of dmesg continuously updated every second in a terminal, while I was trying to discover what caused a (different) program mal-behavior.

Firstly - see the LINK re: Linux / UNIX tail command or maybe HERE at WIKI
OR .. if you have the "info" utility installed - ~$ info tail

Particularly - note the -f option from..
tail [+ number] [-l] [-b] [-c] [-r] [-f] [-c number | -n number] [file]
It stands for "follow", and will allow the tail command to enter an endless loop updated every second.

You can leave any number of various file tell-tails continuously updating on the desktop, mostly useful ones from /var/log. You can set the number of lines, and the snapshot interval.
It might be something like -
Quote:
~$tail -l 15 -f /var/log/dmesg
The are more clever variants that will only update when there is some new change to show. An example is inotail which is a souped-up version of tail

If you are really a determined log-watch geek, I have also heard of multitail which delivers a many-coloured version that does something like tail, grep, diff, watch all at once.
 
Old 08-31-2010, 09:07 AM   #12
GTrax
Member
 
Registered: Oct 2005
Location: UK
Distribution: Mint
Posts: 258

Original Poster
Rep: Reputation: 37
Quote:
Originally Posted by 10110111 View Post
? Or, maybe even
Code:
watch "dmesg|tail"
?
I should not mislead you folks into thinking I am any kind of expert about tail -f, inotail, or multitail. Its easy enough to make the log monitoring work. The real deal is understanding what you read when they deliver, and knowing what to do about it.

~$tail -f /var/log/messages

G

Last edited by GTrax; 08-31-2010 at 09:39 AM.
 
1 members found this post helpful.
Old 08-31-2010, 06:36 PM   #13
GTrax
Member
 
Registered: Oct 2005
Location: UK
Distribution: Mint
Posts: 258

Original Poster
Rep: Reputation: 37
OK friends. This one is now solved!

By using a combination of tail -f on logfiles, and watching processes in Gnome System Monitor, and also getting down & dirty with a dev tool called QDevelop running in debug mode, plus an inspired guess from the program maintainer that crucial dependencies may be missing, did finally cure this one.

I should not have got here at all - given that the needed program and library WAS mentioned in the documentation

Installing pre-compiled from the repository just automatically pulls it all in. Trying to run the application without the other program and its library present is what causes the instant crash.

On the way .. we all get to mess with "top" and "tail" and several other goodies.
G
 
Old 08-31-2010, 07:19 PM   #14
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Quote:
tail -l 15 -f /var/log/dmesg
Ah, I see. Most of my systems do not have a /var/log/dmesg file. I was under the assumption someone was able to get 'dmesg' to run and show a constantly updating screen, possibly by using a for-loop like

user@server# dmesg ; while true
> do
> dmesg | tail -<some wicked cool options here>
> sleep 1
> done
 
1 members found this post helpful.
Old 08-31-2010, 10:53 PM   #15
joec@home
Member
 
Registered: Sep 2009
Location: Galveston Tx
Posts: 291

Rep: Reputation: 70
Quote:
Originally Posted by GTrax View Post
Thanks much for the suggestion. The output from strace is huge! Unfortunately, it also significantly modifies the displayed behavior.
Even so - I can see where strace can be useful.
You can run your program in one shell, then with the "ps" command find the PID (Process ID Number). Then in a different screen connect to the PID with strace.

strace -p 12345
 
2 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to send snmp trap & recieve trap in C program minil Programming 3 07-10-2010 09:22 AM
[SOLVED] Open new shell terminal to allow command entry without crashing main app skipunda Linux - Newbie 3 12-22-2009 08:55 AM
Many complications after crashing first install and crashing and reinstalling several dong Linux - Newbie 1 10-06-2008 04:33 AM
Kernel trap (Fatal trap 12) m!k@EL *BSD 4 09-05-2007 11:58 PM
Login app appears to be crashing on ttyS0 jrog Linux - Software 1 07-20-2006 08:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration