core dumped, where?

Asked by phil

I've just got ubuntu installed (I'm completely new to linux) and I'm trying to get the software I'm writing (C++ with Qt4.3.0) running. I get everything building ok, but when I try to run my app I get:

Segmentation fault (code dumped)

I've no idea what I'm supposed to do with that message. Is there a somewhat helpful dump of program state somewhere I can look at?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Andrew McCarthy
Solved:
Last query:
Last reply:
Revision history for this message
Cesare Tirabassi (norsetto) said :
#1

Have a look in /var/crash
You can find here some suggestions as well on how to debug:

https://wiki.ubuntu.com/DebuggingProgramCrash

Since it is your program the easiest would be to use gdb directly (of course you must compile with the -g flag).

Revision history for this message
phil (zootlewurdle) said :
#2

/var/crash is completely empty.

Revision history for this message
Cesare Tirabassi (norsetto) said :
#3

Then you haven't got apport installed. Have a look here for info on apport:

https://wiki.ubuntu.com/Apport

In any case if a core dump was saved, you should find a file named core, most probably in your home directory.
You can try to find it with this command:

find $HOME -name core

Revision history for this message
phil (zootlewurdle) said :
#4

I have no file named core, even trying to do the find from root, assuming the correct syntax is (as su):

find / -name core

Well, ok, that would return a few results, but none seem to be a likely hit, e.g., finding results in header directories or such.

I apparently do have apport installed because if I try:

apt-get install apport

I get a message back telling me I already have the latest version.

Revision history for this message
phil (zootlewurdle) said :
#5

Digressing slightly from the original question but mentioning it in case it's relevant. The code of mine that appears to be causing the segmentation fault is actually my own crash reporting framework which makes judicious use of try/catch and generates a text file detailing where a crash occurred. Perhaps this is incompatible with whatever ubuntu or indeed other linux versions do with exception/crash trapping?

Revision history for this message
phil (zootlewurdle) said :
#6

Additional: update-notifier shows up in the system monitor, so that's running. According to the wiki apport page that's what runs and watches /var/crash for data before deciding if it needs to launch the apport front end.

Revision history for this message
Best Andrew McCarthy (andrewmccarthy) said :
#7

If it's a core dump of a program that you wrote yourself, normally the file is called "core" and is in the working directory from which you ran it. A segmentation fault is usually a memory-handling error (like an invalid or NULL pointer, for example).

It appears that resource limits (which include the maximum size of a core dump file) are set by PAM on login. The settings for these limits are in /etc/security/limits.conf, which on my system (which is unmodified) is comments only. A quick look at the source code suggests that the default core dump limit is 0 (zero), which means no dump at all is created (even though the message suggests otherwise).

In summary: edit /etc/security/limits.conf, set the core limit to be non-zero (measured in kilobytes), and log in again.

I hope that works!

Revision history for this message
phil (zootlewurdle) said :
#8

OK, the suggested change did cause the core file to be generated, thanks.

Now I need to work out how to make use of it...

:o)

Revision history for this message
phil (zootlewurdle) said :
#9

Thanks Andrew McCarthy, that solved my question.

Revision history for this message
shrutisneha2011@gmail.com (shruti.8) said :
#10

Hey Andrew McCarthy, can you please help me finding the file location "/etc/security/limits.conf" . I am not able to find that file and even after giving command "ulimit -c 10000" , I am getting the same segmentation fault error. Please let me know its solution.