This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Newbie lost with a segmentation fault
- To: help-gcc at gnu dot org
- Subject: Re: Newbie lost with a segmentation fault
- From: John Soltow <jasoltow at erols dot com>
- Date: Thu, 28 Oct 1999 21:57:22 -0400
- Newsgroups: gnu.gcc.help
- References: <3817AC35.4C6C827E@erols.com> <7v8jl3$2fe$2@mughi.cs.ubc.ca>
- Xref: wodc7nx0 gnu.gcc.help:1654
Chris Majewski wrote:
> That's a good book though some of the exercises are tricky!
> The secret to finding seg faults and other bugs is to use gdb, the GNU
> debugger. If you're already using a good editor like Emacs you can run
> this inside your editor (M-x gdb). Gdb expects the name of the
> executable (eg a.out) as its argument. Once inside gdb you can type
> help
> or you can read the Info file on gdb (M-x info RET gdb).
> (Usually seg faults come from pointer bugs like this:
> int *x = 0;
> int y = *x;)
>
> -chris
I'll take a look at it. Yes, I'm using (read: learning) Emacs also.
I found the problem in the code, I'd used a semi-colan following a define -
which compiled depending on how the rest of the code was written, but crashed
when being run.
Thanks for the help,
John
>
>
> John Soltow <jasoltow@erols.com> wrote:
> > I'm in the process of teaching myself C through "The C Programming
> > Language" (Brian Kernighan & Dennis Ritchie) and
> > am having problem with a piece of code. The code compiles ok (using GCC
> > under Linux), but segmentation faults when run.
>
> > I'm not as concerned about what is wrong with the code (for the
> > purpose of this message) as I am with how to go about finding the
> > problem when I get a seg fault/core dump. In this case, everything in
> > the code looks fine. I know from reading elsewhere in Usenet that the
> > core file can be used as a troubleshooting aid in finding the problem in
> > the code. Can someone point me to the documentation that explains how
> > to do that?
>
> > If it matters, I'm running gcc version egcs-2.91.66 19990314/Linux
> > (egcs-1.1.2 release)
>
> > Thanks,
> > John Soltow