Stopping Segmentation fault in GCC 4.2.3

Discussion in 'C++' started by solarrobor, Apr 14, 2008.

  1. solarrobor

    solarrobor Guest

    I have just bought the book "The Shellcoder's Handbook" 2nd Ed. I am
    currently trying the examples that they give in the book but on my
    Fedora 8 running gcc 4.2.3 I always get a segmentation fault when
    trying to do the stack overflow examples. As a result I don't get the
    same results when I run the executables created from the examples.

    Does anybody know you I can prevent the segmentation fault from
    appearing, is there a switch or do I need to get an earlier version of
    GCC?

    Thanks.
     
    solarrobor, Apr 14, 2008
    #1
    1. Advertising

  2. solarrobor

    James Kanze Guest

    On Apr 14, 7:43 pm, solarrobor <> wrote:
    > I have just bought the book "The Shellcoder's Handbook" 2nd Ed. I am
    > currently trying the examples that they give in the book but on my
    > Fedora 8 running gcc 4.2.3 I always get a segmentation fault when
    > trying to do the stack overflow examples. As a result I don't get the
    > same results when I run the executables created from the examples.


    > Does anybody know you I can prevent the segmentation fault from
    > appearing, is there a switch or do I need to get an earlier version of
    > GCC?


    Don't do whatever causes the segment violation. You mention
    stack overflow; stack overflow is undefined behavior, but will
    cause a segment violation all of the compilers I know. Or are
    you doing something else wrong? (Without any code, it's
    impossible to say.)

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Apr 15, 2008
    #2
    1. Advertising

  3. solarrobor

    James Kanze Guest

    On Apr 14, 8:00 pm, "Victor Bazarov" <> wrote:
    > solarrobor wrote:
    > > I have just bought the book "The Shellcoder's Handbook" 2nd Ed. I am
    > > currently trying the examples that they give in the book but on my
    > > Fedora 8 running gcc 4.2.3 I always get a segmentation fault when
    > > trying to do the stack overflow examples. As a result I don't get the
    > > same results when I run the executables created from the examples.


    > > Does anybody know you I can prevent the segmentation fault from
    > > appearing, is there a switch or do I need to get an earlier version of
    > > GCC?


    > Your question seems to be GCC specific.


    Does it? With g++ (as with all other Unix based compilers I
    know), there are only two things which can cause a segmentation
    fault: undefined behavior in your code, or an error in the
    compiler (causing it to generate wrong code). Without actually
    seeing the code in question, we can't be sure which it is, but I
    know which one I'd bet on.

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Apr 15, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Hunsley
    Replies:
    17
    Views:
    873
  2. Pud
    Replies:
    0
    Views:
    582
  3. Replies:
    0
    Views:
    538
  4. jaswinder
    Replies:
    15
    Views:
    4,066
    Barry Schwarz
    Aug 14, 2010
  5. John Ladasky
    Replies:
    3
    Views:
    141
    Laurent Pointal
    Nov 10, 2013
Loading...

Share This Page