Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] runtime error for c++ prog

On Thu, 31 Oct 2002, Bart s wrote:

> believe that the core is the Linux kernel

Not really. If you find someone with a gray beard they might be able to
show you some "core". Early machines had ferrite donuts (cores) for their
memory, and therefore a core dump was merely dumping the content of

The use of the term hasn't changed -- just the use of the donuts (we eat
the now). It's telling you that there was a memory access violation, and
that it saved a copy of the state of the app's memory before it crashed so
you can debug.

> and I guess that this message
> comes from the operating system.

Yeah. You've done something naughty with memory.

> I was wondering if anybody could tell me
> what a segmentation fault is and suggest what sort of thing could be wrong
> with my program.

I think I've done that bit now... You're probably looking at an off by one
bug or something (reading in one too many values into your array, or not
starting the array at zero). To confirm this, just make the array way big
and see if it still crashes.

If you want to be hard "core", then try this:

gdb <appname> core

When it has started (it should say a heap of stuff about loading symbols),
then just type

This will show you a call stack of all the functions which happened just
before the crash. Unfortunately c++ has heaps of plumbing, so this
sometimes needs a bit of a dig through.

Note that depending on your distro, core might be named core.<pid>, and
that you need debugging support turned on in your app for gdb to be really
useful here. You do that with gcc with the -ggdb switch, I'm not sure
what it is for c++.



Michael Still (mikal@xxxxxxxxxxx)     UTC +10 hours