Re: Segfault only with optimization
- From: Flash Gordon <spam@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 17 Mar 2008 22:40:43 +0000
jacob navia wrote, On 17/03/08 21:45:
santosh wrote:jacob navia wrote:
Peter Nilsson wrote:Jeff Taylor <dev.n...@xxxxxxxx> wrote:Interesting interesting...I have a C program that GCC compiles without warnings andRealise that output is not the only measure of correctness.
it runs just fine.
Can you name any other measure that doesn't rely on
output?
A program that invokes a buffer overrun, but happens to produce expected
output is surely not correct?
How the hell do you know that there is a buffer
overrun if the output is not affected?
To KNOW that there is a buffer overrun the program MUST
do something it should not do, i.e. produce an output
that is different than the expected output
If the output of the program is normal you have NO WAY
to know there is a buffer overrun.
You obviously do not understand what static analysis is. Or what reviews are for that matter! Just to explain...
Static analysis is when you analyse the code *without* running it. Various methods of static analysis are used on safety critical software (in my previous job we were going to contract out the static analysis of the code to a third party, I know this because I was going out with one of out SW QA engineers visiting the companies to evaluate them). Since in static analysis you do not run the code you cannot sensibly consider the report produced (which should certainly include identifying buffer overflows) as an output of the program any more than you can consider 1.1415926536 to be the output of a text file containing only the character "2" in it (it is the output of the program that runs on the file).
And if you hook a debugger and see some buffer being
overrun that *is* output of course.
I suppose you will consider the report by an independent company that never runs the program to be output of the program as well. Also I suppose the minutes of the design review (held before a line of code is written) is an output of the program, and yes bugs *are* found in design reviews if they are held properly.
Using a psychic medium is not allowed.
Deep thought.However, when I compile it using any of the -O optionsI'm afraid you are responsible for diagnosing errors in your
(-O0, -O1, etc.) it segfaults when executed (still no
compiler warnings or errors).
code, not your compiler.
He means semantic errors. Or does your compiler do the programming for
the programmer? :-)
<snip>
What I mean is that such sentences are not helpful to the OP.
And we should try to be less patronizing with newcomers and
people that ask questions. I am sure the OP knows that it is the
programmer that debugs the program. He was asking us to help him
to do that, not to answer him
just do it pal...
The implication of what the OP posted was that he found it surprising that he would get a segfault on code that did not produce a warning, this is a common mistake. So pointing out that the compiler is not responsible for finding the errors is not unhelpful.
Personally I would start by turning up the warnings on the compiler and fixing the issues that throws up (as someone else suggested) and then try running it through valgrind (as someone else suggested).
--
Flash Gordon
.
- Follow-Ups:
- Re: Segfault only with optimization
- From: jacob navia
- Re: Segfault only with optimization
- References:
- Segfault only with optimization
- From: Jeff Taylor
- Re: Segfault only with optimization
- From: Peter Nilsson
- Re: Segfault only with optimization
- From: jacob navia
- Re: Segfault only with optimization
- From: santosh
- Re: Segfault only with optimization
- From: jacob navia
- Segfault only with optimization
- Prev by Date: Re: which tutorial to use?
- Next by Date: Re: which tutorial to use?
- Previous by thread: Re: Segfault only with optimization
- Next by thread: Re: Segfault only with optimization
- Index(es):
Relevant Pages
|