SUMMARY:core dumps

From: Oscar Goldes (
Date: Fri May 30 1997 - 19:00:37 CDT

Original question

>trying to debug a couple of apps that now and then fall, I would like to
know more about core dumps:
>1. I think I know that "segmentation fault" means that the program has tried
>to access memory he does not own. I am right? Another cause?
>2. What are the most likely causes of "bus error"?? (Not including the
following one)
>3. Why sometimes, if you copy over the disk file of a process that is
executing it falls with bus error and sometimes not?
>4. What useful information can be extracted from the core file with adb or
another tools?

Thanks for all answers, which were:

1. A segmentation fault is an attempt to access a memory address that is
not part of the process virtual memory. In most cases (if you program in C)
it means an uninitialized pointer or pointer corruption.

2. There are two kinds of bus error. One is an attempt to access a physical
or bus address (could be SBUS, etc) that does not exist.

The other is an attempt to make an unaligned transfer to an address. For
example, a long transfer (4 bytes) must use an address that is aligned on a 4
byte address (0, 4, 8, etc). An address aligned on a short alignment (2, 6,
will fail for a long transfer.
Again, in C that could mean for example calling a function with a missing
argument. Another case is in the answer to question 3.

3. If a program is being executed (say /home/xxx) and you copy another
version over it (for example, by recompiling or cp /home/yyy /home/xxx),
the process will dump core with a bus error if the process gets swapped out
of memory. When the OS tries to reload it, he finds that is no longer the
same he swapped out, and gives a core dump due to bus error. This does not
happen if the process does not get swapped to disk.

4. I have received several suggestions:
strings core|more might throw some light
adb progname core and then $c will show the function call that caused the
core dump. then
function-name?nn i
will show the nn first lines of the un-assembled listing of the function
function-name, which may be useful.
To get most of adb, you need an unstripped executable, that contains some
symbolic info. If it is not there, you can reconstruct some of it with a
program called unstrip
You can see the register values at the moment of the fault, and an image of
the process memory.

Thanks to all who replied. The answers were, as allways are in this group,
very precise.

-- Oscar Goldes
-- Orden Argentina SA

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:56 CDT