Stopping Segmentation fault in GCC 4.2.3

S

solarrobor

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.
 
J

James Kanze

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.)
 
J

James Kanze

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top