help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debugging to find Segmentation Fault


From: Paul Pluzhnikov
Subject: Re: Debugging to find Segmentation Fault
Date: Tue, 16 May 2006 09:45:11 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

Cleverbum@hotmail.com writes:

>  I'm a complete beginner,

Yes, we can tell :)

> having written my second program and finally
> got it to compile, I've got an error I can't track down occurring at
> runtime - basically whatever I do it says Segmentation Fault.

It is time for you to master the skill of debugging.

Exactly how you go about it is different on different platforms (and
you didn't provide any clues as to which platform you are using).

However, given this:

> X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; ...

I'll assume that you are on Linux. Here is one place to start
learning how to debug programs with gdb:
http://www.delorie.com/gnu/docs/gdb/gdb_toc.html

>  I was wondering if there was any way I could get a slightly more
> verbose description of the error so that I could think about sorting it
> out.

The debugger will provide much of that info.

>  Someone mentioned to me that the g++ option -DRANGE_CHECKING would
> check if i was accessing uninitialised arrays or something at compile
> time, but that hasn't helped,

There is no magic gcc *define* that will do range-checking (so
whoever told you to add -DRANGE_CHECKING is likely a novice himself).

Besides, you don't even know yet whether your problem is related
to range checking, or is something else entirely.

That said, recent versions of gcc on x86 do impplement range
checking. Compile your program this way:

  g++ -g -fmudflap foo.cc ... -lmudflap

Note however, that I've had mixed results with mudflap and C++ code:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19319

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]