Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Seg fault even though address space is accessible

Reply
Thread Tools

Seg fault even though address space is accessible

 
 
31349 83652
Guest
Posts: n/a
 
      07-31-2008
Ajay wrote:
> I haven't figured out what are best compiler options yet.


I can't help you there (and the options may change for
each translation unit), but maybe you'd like to try


gcc -Werror ...

-Werror
Make all warnings into errors.


 
Reply With Quote
 
 
 
 
Antoninus Twink
Guest
Posts: n/a
 
      07-31-2008
On 31 Jul 2008 at 6:45, Chris Dollin wrote:
> Antoninus Twink wrote:
>> Fact is, *noone* has claimed to be able to debug code using only a
>> debugger and not seeing the source code. *You* on the other hand (and
>> many of your lackeys and lickspittles) have claimed on many occasions
>> that you can debug any problem using only a printout of the source code
>> and never a debugger.

>
> Cite three instances that fit this claim.


Happily. In fact, here are five.

Malcolm Maclean, <(E-Mail Removed)>
> My view on this is that the debugger creates a very intimate
> relationship with the programmer. When I first learnt C I used one.
> The run / debug cycle becomes a natural way of working. Then In my
> first job I got a Unix box and suddenly the debugger was taken away.
> Then I got another one for a games console, but it wasn't well
> designed. I decided at that point that even a good debugger was too
> seductive. So now I use diagnostics almost exclusively.


Bartc, <MPDCj.23573$(E-Mail Removed)>
> I've never used debuggers either, for either hardware or software.
> Tracking down an elusive bug is more like a sport; a proper debugger
> would spoil the fun.



Ian Collins, <(E-Mail Removed)>
> As I've said here before, spend some time (at least a year) working in
> a language without a debugger, you will very quickly adapt to life
> without it.



Ed Prochik,
<(E-Mail Removed)>
>> 1500-2000 lines is the maximum the brain can handle.

>
> So then keep you code size below that limit and you will not need the
> debugger.



And the Prince Of Lies himself, Richard Heath Field,
<(E-Mail Removed)>
> I have certainly debugged what you consider to be impossibly large
> code bases without using a debugger.
>
>> nobody believes this "I can debug without a debugger" stuff.

>
> ...except those who've done it, of course, which seems to be most of
> us.



Once again, I call bullshit on Heathfield's claims to be a superhero.

We've all seen Heathfield spew out lie after lie to undermine Jacob and
try to destroy his reputation. It's no surprise that he tries to blacken
the "trolls" who've got the measure of him with the same sort of slurs.

Heathfield is a liar, morning, noon and night.

 
Reply With Quote
 
 
 
 
Nick Keighley
Guest
Posts: n/a
 
      08-01-2008
On 1 Aug, 00:54, Antoninus Twink <(E-Mail Removed)> wrote:
> On 31 Jul 2008 at *6:45, Chris Dollin wrote:
> > Antoninus Twink wrote:


> >> Fact is, *noone* has claimed to be able to debug code using only a
> >> debugger and not seeing the source code. *You* on the other hand (and
> >> many of your lackeys and lickspittles) have claimed on many occasions
> >> that you can debug any problem using only a printout of the source code
> >> and never a debugger.

>
> > Cite three instances that fit this claim.

>
> Happily. In fact, here are five.


the key sentence in your quote is:

"You [Richard Heathfield] [...] have claimed on many occasions that
you can
debug any problem using ONLY a printout of the source code and NEVER
a
debugger"

I do not believe my elision or change in emphasis has distorted
what you say. The original is still available above.

1. RCH never said he nver used a debugger
2. none of the quotes below claim to only use a printout.
Many use diagnostics.

So you have made two untrue statements. Since you have done
this repeatedly this makes you a liar.



>
> Malcolm Maclean, <(E-Mail Removed)>
>
> > My view on this is that the debugger creates a very intimate
> > relationship with the programmer. When I first learnt C I used one.
> > The run / debug cycle becomes a natural way of working. *Then In my
> > first job I got a Unix box and suddenly the debugger was taken away.
> > Then I got another one for a games console, but it wasn't well
> > designed. I decided at that point that even a good debugger was too
> > seductive. So now I use diagnostics almost exclusively.

>
> Bartc, <MPDCj.23573$(E-Mail Removed)>
>
> > I've never used debuggers either, for either hardware or software.
> > Tracking down an elusive bug is more like a sport; a proper debugger
> > would spoil the fun.

>
> Ian Collins, <(E-Mail Removed)>
>
> > As I've said here before, spend some time (at least a year) working in
> > a language without a debugger, you will very quickly adapt to life
> > without it.

>
> Ed Prochik,
> <(E-Mail Removed)>
>
> >> 1500-2000 lines is the maximum the brain can handle.

>
> > So then keep you code size below that limit and you will not need the
> > debugger.

>
> And the Prince Of Lies himself, Richard Heath Field,
> <(E-Mail Removed)>
>
> > I have certainly debugged what you consider to be impossibly large
> > code bases without using a debugger.

>
> >> nobody believes this "I can debug without a debugger" stuff.

>
> > ...except those who've done it, of course, which seems to be most of
> > us.

>
> Once again, I call bullshit on Heathfield's claims to be a superhero.
>
> We've all seen Heathfield spew out lie after lie to undermine Jacob and
> try to destroy his reputation. It's no surprise that he tries to blacken
> the "trolls" who've got the measure of him with the same sort of slurs.
>
> Heathfield is a liar, morning, noon and night.



--
Nick Keighley

"Anyone attempting to generate random numbers by deterministic
means is, of course, living in a state of sin."
-- John Von Neumann

 
Reply With Quote
 
Harald van Dijk
Guest
Posts: n/a
 
      08-01-2008
On Fri, 01 Aug 2008 09:52:54 -0400, CBFalconer wrote:
> Ajay wrote:
>> I haven't figured out what are best compiler options yet. But I can
>> make sure next time that I go thru the list warning msgs.

>
> One line, probably wrapped, below:
>
> *gcc -W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal -gstabs+
> -ftrapv
>
> (you may want to replace ansi with std=c99)


Why do you want to use -ansi if you're going to include another option
that deliberately makes the compiler fail to conform to any standard?
 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      08-02-2008
CBFalconer <(E-Mail Removed)> writes:

> Harald van D?k wrote:
>> CBFalconer wrote:
>>> Ajay wrote:
>>>
>>>> I haven't figured out what are best compiler options yet. But
>>>> I can make sure next time that I go thru the list warning msgs.
>>>
>>> One line, probably wrapped, below:
>>>
>>> *gcc -W -Wall -ansi -pedantic -Wwrite-strings -Wfloat-equal
>>> -gstabs+ -ftrapv
>>>
>>> (you may want to replace ansi with std=c99)

>>
>> Why do you want to use -ansi if you're going to include another
>> option that deliberately makes the compiler fail to conform to
>> any standard?

>
> And what do you consider does that? A warning does not prevent
> compilation.


Consider the following:

void f(const char (*cp)[4]);

void g(void)
{
f(&"abc");
}

It requires a diagnostic which -Wwrite-strings suppresses.

--
Ben.
 
Reply With Quote
 
Harald van Dijk
Guest
Posts: n/a
 
      08-02-2008
On Fri, 01 Aug 2008 22:59:14 -0400, CBFalconer wrote:
> Ben Bacarisse wrote:
>> CBFalconer <(E-Mail Removed)> writes:
>>> Harald van D?k wrote:
>>>

> ... snip ...
>>>>
>>>> Why do you want to use -ansi if you're going to include another
>>>> option that deliberately makes the compiler fail to conform to any
>>>> standard?
>>>
>>> And what do you consider does that? A warning does not prevent
>>> compilation.

>>
>> Consider the following:
>>
>> void f(const char (*cp)[4]);
>>
>> void g(void) { f(&"abc"); } /* modified cf */
>>
>> It requires a diagnostic which -Wwrite-strings suppresses.

>
> I don't see that. Are you confused about the meaning of
> -Wwrite-strings?


He's not.

The type of "abc" according to the standard is char[4], not const char[4].
And the type of &"abc" is char(*)[4], not const char(*)[4]. There is no
implicit conversion from char(*)[4] to const char(*)[4], so Ben's code
violates a constraint. And if you make the code

void f(char (*cp)[4]);
void g(void) { f(&"abc"); }

then the code is correct, no constraint is violated, and gcc will accept
the code, but it will emit a very misleading diagnostic strongly
suggesting the code is incorrect.

Admittedly a stretch, but you can even get gcc to reject valid code with
your options:

void f(void) { *"" = 0; }

This is allowed in a strictly conforming program as long as f is never
called, yet gcc will issue a hard error for it with your options. At least
you won't find this one outside of a conformance test though.
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      08-02-2008
Harald van D?k wrote:
>

.... snip ...
>
> The type of "abc" according to the standard is char[4], not const
> char[4]. And the type of &"abc" is char(*)[4], not const char(*)[4].
> There is no implicit conversion from char(*)[4] to const char(*)[4],
> so Ben's code violates a constraint. And if you make the code
>
> void f(char (*cp)[4]);
> void g(void) { f(&"abc"); }
>
> then the code is correct, no constraint is violated, and gcc will
> accept the code, but it will emit a very misleading diagnostic
> strongly suggesting the code is incorrect.
>
> Admittedly a stretch, but you can even get gcc to reject valid code
> with your options:
>
> void f(void) { *"" = 0; }
>
> This is allowed in a strictly conforming program as long as f is
> never called, yet gcc will issue a hard error for it with your
> options. At least you won't find this one outside of a conformance
> test though.


However I maintain that anyone trying to perform those operations
will write the following code, eliminating the confusing '&', and
which triggers nothing:

#include <stdio.h>
void f(const char *cp) {puts(cp);}

void g(void) {f("abc");}

int main (void) {g(); return 0;}

Admittedly, the option can cause misleading diagnostics, but the
code still compiles. What it does is warn me about writing to a
non-writable string. And the option is there because of the
historic status of non-writable strings.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.


 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      08-02-2008
CBFalconer <(E-Mail Removed)> writes:

> Harald van D?k wrote:

<snip>
>> There is no implicit conversion from char(*)[4] to const char(*)[4],
>> so Ben's code violates a constraint.

<snip>
> However I maintain that anyone trying to perform those operations
> will write the following code, eliminating the confusing '&',


I don't see how that alters the argument. If a set of options make a
compiler non-conforming, then re-writing the code does not make it
conforming.

With the code I posted, the options you suggest make gcc
non-conforming and you can't just re-write the parameter type and the
call to eliminate "the confusing &" without making the code quite
different.

> Admittedly, the option can cause misleading diagnostics, but the
> code still compiles.


And, in one case, fails to produce a required diagnostic.

> What it does is warn me about writing to a
> non-writable string. And the option is there because of the
> historic status of non-writable strings.


Yes, it is a useful option but it is more useful if you know those
cases where it makes gcc non-conforming.

--
Ben.
 
Reply With Quote
 
Richard
Guest
Posts: n/a
 
      08-02-2008
CBFalconer <(E-Mail Removed)> writes:

> Harald van D?k wrote:
>>

> ... snip ...
>>
>> The type of "abc" according to the standard is char[4], not const
>> char[4]. And the type of &"abc" is char(*)[4], not const char(*)[4].
>> There is no implicit conversion from char(*)[4] to const char(*)[4],
>> so Ben's code violates a constraint. And if you make the code
>>
>> void f(char (*cp)[4]);
>> void g(void) { f(&"abc"); }
>>
>> then the code is correct, no constraint is violated, and gcc will
>> accept the code, but it will emit a very misleading diagnostic
>> strongly suggesting the code is incorrect.
>>
>> Admittedly a stretch, but you can even get gcc to reject valid code
>> with your options:
>>
>> void f(void) { *"" = 0; }
>>
>> This is allowed in a strictly conforming program as long as f is
>> never called, yet gcc will issue a hard error for it with your
>> options. At least you won't find this one outside of a conformance
>> test though.

>
> However I maintain that anyone trying to perform those operations
> will write the following code, eliminating the confusing '&', and


And now the illustrious Chuck, having been schooled in gcc command line
options, proceeds to tell us how others will write their code!

Only in c.l.c

Reading a few Heathfield and Chuckster threads on a hot summer's evening
leaves me puffing from laughter! The arrogance! The egos! Wonderful
entertainment.

And for real C schooling one can read the rest.

> which triggers nothing:
>
> #include <stdio.h>
> void f(const char *cp) {puts(cp);}
>
> void g(void) {f("abc");}
>
> int main (void) {g(); return 0;}
>
> Admittedly, the option can cause misleading diagnostics, but the
> code still compiles. What it does is warn me about writing to a
> non-writable string. And the option is there because of the
> historic status of non-writable strings.


--
 
Reply With Quote
 
Chris Dollin
Guest
Posts: n/a
 
      08-04-2008
Antoninus Twink wrote:

> On 31 Jul 2008 at 6:45, Chris Dollin wrote:
>> Antoninus Twink wrote:
>>> Fact is, *noone* has claimed to be able to debug code using only a
>>> debugger and not seeing the source code. *You* on the other hand (and
>>> many of your lackeys and lickspittles) have claimed on many occasions
>>> that you can debug any problem using only a printout of the source code
>>> and never a debugger.

>>
>> Cite three instances that fit this claim.

>
> Happily. In fact, here are five.


As Richard Heathfield observes elsethread, not one of your examples
fits the claim you made. Such transparent failure is its own reward.

--
'It changed the future .. and it changed us.' /Babylon 5/

Hewlett-Packard Limited registered no:
registered office: Cain Road, Bracknell, Berks RG12 1HN 690597 England

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU Usage frequently 100% even though it seems not even close tototal memory Newcomer Computer Support 3 11-15-2009 06:51 AM
CPU Usage frequently 100% even though it seems not even close tototal memory Newcomer Computer Support 0 11-14-2009 11:21 PM
Wireless adapter losing network address even though signal is strong... Howard Woodard Wireless Networking 2 07-11-2009 07:21 PM
seg fault because stdexcept.cc not found? Corrine C++ 1 11-27-2003 06:15 AM
Suprising seg fault!!! Vinod C++ 3 09-27-2003 02:43 PM



Advertisments