Which entity in a system detects segmentation fault ?

S

syuga2012

Hi Folks,

I would like to know, which entity in a system (MMU, OS etc) detects
segmenation fault e.g buffer overflow. How does it know that a
segmentation fault has occured?

Thanks,
syuga
 
D

dj3vande

Hi Folks,

I would like to know, which entity in a system (MMU, OS etc) detects
segmenation fault e.g buffer overflow. How does it know that a
segmentation fault has occured?

Which system?

Your terminology suggests that you're using some unix flavor; in that
case, comp.unix.programmer might be a good place to start. (They might
point you at somewhere better.)

There's nothing in the language definition that requires the type of
error that some systems call a segmentation fault to be detected.
On systems that do detect it, it's likely to be some sort of (probably
hardware-assisted) OS magic, but there's no reason why it can't be done
with checks generated by the C compiler.


dave
 
F

Flash Gordon

Hi Folks,

I would like to know, which entity in a system (MMU, OS etc) detects
segmenation fault e.g buffer overflow. How does it know that a
segmentation fault has occured?

It depends entirely on the system, and on some systems there is no such
thing as a "segmentation fault" and nothing which even vaguely resembles
one. Normally where it does exist some of the hardware does the
detection in some manner, but to find out what and how you need to ask
in groups dealing with the systems that interest you.
 
K

Keith Thompson

I would like to know, which entity in a system (MMU, OS etc) detects
segmenation fault e.g buffer overflow. How does it know that a
segmentation fault has occured?

That's not a C question. You might have better luck asking in
comp.programming or in a newsgroup for your operating system.
 
K

Kaz Kylheku

Hi Folks,

I would like to know, which entity in a system (MMU, OS etc) detects
segmenation fault e.g buffer overflow. How does it know that a
MMU

segmentation fault has occured?

This is a machine architectures question: try comp comp.arch.

Some textbook ideas:

_Computer Architecture: A Quantitative Approach_, Hennesy and Patterson

_Computer Organization and Architecture_, William Stallings
 
A

Antoninus Twink

That's not a C question.

As usual, this is a bare-faced lie.


$ cat foo.c
int main(void)
{
char *t = 0;
return *t = 0;
}
$ cc -o a a.c
$ ./a
Segmentation fault


Not a C question? Get real.

Anyway, what happens is that the MMU gets sent an invalid page table
entry. It generates a "page fault", which is a hardware trap. This is
handled by the kernel, which then checks whether the address is in the
process's virtual address space with the right permissions. If not, it
sends the process a SIGSEGV.

So it's *both* the hardware *and* the kernel that work together to
generate everyone's favorite message, "Segmentation fault".
 
D

Dik T. Winter

>
> As usual, this is a bare-faced lie.
>
>
> $ cat foo.c
> int main(void)
> {
> char *t = 0;
> return *t = 0;
> }
> $ cc -o a a.c
> $ ./a
> Segmentation fault

Do you know that I have used systems where that program would run to completion
without faulting?

Do you know that I have used systems where that program would give the error
message "Memory access violation"?

In what way does any form of C mandate that the error will be
"Segmentation fault"?
> Anyway, what happens is that the MMU gets sent an invalid page table
> entry.

I am very sorry. The computer I am now using does not have a MMU.
 
L

Larry Gates

Do you know that I have used systems where that program would run to completion
without faulting?

Do you know that I have used systems where that program would give the error
message "Memory access violation"?

In what way does any form of C mandate that the error will be
"Segmentation fault"?


I am very sorry. The computer I am now using does not have a MMU.

But antonius did have the C the fella was looking for.
 
P

Phil Carmody

Why snip that? It's 100% relevant to the (heading off-topic) subject
of what's a meaningful question on this ng.

[SNIP - typical twink crap not addressing either the question or
anything to do with programming valid C.]

....
But antonius did have the C the fella was looking for.

WTF? The fella wasn't looking for C:

I would like to know, which entity in a system (MMU, OS etc) detects
segmenation fault e.g buffer overflow. How does it know that a
segmentation fault has occured?

No mention of C in that question at all. It was a completely nebulous
question about computer architectures, and as Dik correctly pointed
out it contained incorrect presumptions about same.

Phil
 
L

Larry Gates

Why snip that? It's 100% relevant to the (heading off-topic) subject
of what's a meaningful question on this ng.

[SNIP - typical twink crap not addressing either the question or
anything to do with programming valid C.]

...
But antonius did have the C the fella was looking for.

WTF? The fella wasn't looking for C:

I would like to know, which entity in a system (MMU, OS etc) detects
segmenation fault e.g buffer overflow. How does it know that a
segmentation fault has occured?

No mention of C in that question at all. It was a completely nebulous
question about computer architectures, and as Dik correctly pointed
out it contained incorrect presumptions about same.

Phil

Oh. I thought it meant something in linux, which isn't my thing. Dan pop
told me not to read that chapter of K&R2. Maybe this would be a good time
to defy Dan.
 
I

Ian Collins

Larry said:
Oh. I thought it meant something in linux, which isn't my thing. Dan pop
told me not to read that chapter of K&R2. Maybe this would be a good time
to defy Dan.

WFT are you on? K&R2 pre-dates Linux.
 
L

Larry Gates

WFT are you on? K&R2 pre-dates Linux.

K&R 1 eng 1978
" 1 deutsch 83
" 2 88 ?
" deutsch 2 92?
--
larry gates

Does the same as the system call of that name.
If you don't know what it does, don't worry about it.
-- Larry Wall in the perl man page regarding chroot(2)
 
P

Phil Carmody

Larry Gates said:
Oh. I thought it meant something in linux, which isn't my thing.

And even if it were to, how would that make it relevant to c.l.c?
Dan pop told me not to read that chapter of K&R2.

Dan Pop's said a lot of things in his time, but I reckon that
not one of them concerned the non-existent chapter about linux
in K&R2.
Maybe this would be a good time to defy Dan.

Maybe now would be a good time to work out what is and isn't the
C programming language.

Phil
 
K

Kaz Kylheku

In a typical system with virtual-memory hardware, the MMU detects
an unmapped page access, and the OS detects that there is no page
to swap in to continue the program.

In a typical system with no MMU, *nothing* detects a segmentation
fault, and one never happens.

It is possible for a system with no MMU to detect accesses to
non-installed physical memory, often as an ECC error or memory
parity error.

Simple fence registers can establish a range of memory that a currently running
program can access, thereby protecting adjacent programs. Fiddling with the
fence registers can be a privileged instruction that traps into the OS.
As an added benefit, fence registers can provide a relocation mechanism,
so that every task can have its own address zero, and be compiled for
a fixed logical address.
 
L

Larry Gates

And even if it were to, how would that make it relevant to c.l.c?


Dan Pop's said a lot of things in his time, but I reckon that
not one of them concerned the non-existent chapter about linux
in K&R2.


Maybe now would be a good time to work out what is and isn't the
C programming language.

Phil

I can be wrong on this, but I'll bring §8 with me to serenade the stars in
my southwestern desert jewel. The amount I read is proportional to the bad
singing.

CHAPTER 8: T u s sissies.
--
larry gates

Remember though that
THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR.
-- Larry Wall in the perl man page
 
P

Phil Carmody

Larry Gates said:
I can be wrong on this, but I'll bring §8 with me to serenade the stars in
my southwestern desert jewel. The amount I read is proportional to the bad
singing.

CHAPTER 8: T u s sissies.

Which section of chapter 8 mentions Linux?

Stop trying to obfuscate your ignorance by using silly poetic
metaphors. On this group you should get clever with C before
trying to getting clever with English.

Phil
 
B

baeuar

As usual, this is a bare-faced lie.

$ cat foo.c
int main(void)
{
  char *t = 0;
  return *t = 0;}

$ cc -o a a.c
$ ./a
Segmentation fault
No exatly, some systems run this program without giving any seg fault,
but with unbpredictable results. it depends on the way the system
handles these.
 
L

Larry Gates

Leave the guy alone. For someone who sided with you and insulted
me and a few others a while back, he sure does get treated like
shit by members of the clique. We had Heathfield implying he
was me (yes, I sympathize with anyone who gets that insult!) and
Dave Thompson calling him "loopy" -- now we have you fuckwits
picking on his writing.

I used to think the guy was either nuts or a clever troll, and
I couldn't always see any sense in what he was saying, but then
I saw during his "sequence points" thread that he simply doesn't
bother spelling things out in complete detail. His only crime
appears to be assuming too much about the ability of our
literalist regulars to draw inferences.


Yours,
Han from China

But then there's chapter 8 of K&R2, entitled The Unix System Interface,
which is a counterclaim like so much.

My material counterclaim begins with DARPA and Keith thompson claiming my
criticsm OT.

Since felonies aren't spelled out in the standard, they are OT in KT's clc.
 
J

James Kuyper

Larry Gates wrote:
....
But then there's chapter 8 of K&R2, entitled The Unix System Interface,
which is a counterclaim like so much.

You were asked to identify the chapter which you claimed to exist which
discussed Linux, not Unix.

Chapter 8, of course, merely gives out-of-date examples of how C can be
used to interact with one particular operating system; it does not
render questions specific to that operating system relevant to C as a
whole. If it did, then by that same argument, if K&R had contained an
example of a program for managing a grocery store's inventory, then
questions about the best place to buy apples wholesale would be
considered legitimate C programming questions.
 
L

Larry Gates

Larry Gates wrote:
...

You were asked to identify the chapter which you claimed to exist which
discussed Linux, not Unix.

Chapter 8, of course, merely gives out-of-date examples of how C can be
used to interact with one particular operating system; it does not
render questions specific to that operating system relevant to C as a
whole. If it did, then by that same argument, if K&R had contained an
example of a program for managing a grocery store's inventory, then
questions about the best place to buy apples wholesale would be
considered legitimate C programming questions.

Linux v unix; I astound how I can mention the generalities withoout being
given the points.

James, do you acknowledge the folks who have already gotten away with
fraud?

Can no one make it retroactive?
 

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,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top