Bugtraq mailing list archives

Re: Segmentation Faults


From: blymn () awadi com AU (Brett Lymn)
Date: Thu, 6 Oct 1994 17:15:24 +0930 (CST)


According to Michael Bresnahan:

What is the mechanism that produces a segmentation violation while a users
code is executing.

Referencing a location that is outside the user's dataspace.  Note
that on some machines there is a bit of slop in this as the memory
protection works on kernel page click boundaries.

 How does the kernel control the situation when at the
time it is not even executing?  Does it use a interupt? 

They are not usually called interrupts in this context they are called
traps.

If so, could someone
explain how this works (a basic understanding of what a interupt is and how
it works would help me here)?

In a normally running process there are pages of memory that are
desginated as being read/write, known as data pages.  Other pages are
read only, which contain the program executable and other such things,
these pages are known as text pages.  The system's memory management
unit (MMU) is set up to allow the processor to read/write the data
pages and read the text pages.  If the processor tries to write a page
that is marked read only or access a page not in the process space
then the MMU flags the access as invalid that causes a trap in the
processor which invokes the trap routine to handle the invalid access
which usually means sending a SIGSEGV to the offending process.

 if it does rely on the hardware (I assuming
perhaps incorrectly that such a interupt must have hardware support), how
does that effect the porting of UNIX to different machine
architectures?

Yes it relies on hardware support to work.  The trap handling stuff is
one of the few portions of unix that is very machine specific.

Specifically it interests me how UNIX is implememted on intel x86 machines
which being designed to run single user OS's might not have the proper      
hardware support for multitasking OS's.


No this is not correct, {3,4,5}86 chips have support for memory
protection (viz "protected mode").  Unix implementations take
advantage of this facility, it is only that horrible MS products that
are only just starting to use this mode instead of pretending the chip
is just a fast 8086.

-- 
Brett Lymn, Computer Systems Administrator, AWA Defence Industries
===============================================================================
"Aha!  Pronoun problems.  It's not `shoot you, shoot you', it's `shoot me,
 shoot me'.  So, go ahead, shoot ME, shoot ME <BLAM>... You're Despicable"
                        -- Daffy Duck



Current thread: