Many thanks!
Ted Sternberg
San Jose, California, USA
--
Theodore Sternberg <str...@rahul.net>
Yes, you are being a little vague. It has various meanings on
different machines, but it is generally caused by a memory access
error: ie. you were reading or writing where you weren't supposed to
in memory.
The main culprit, besides running off the end of an array or using an
invalid pointer (esp. NULL pointers) is non-aligned memory accesses: on
some machines, types with size > 1 (eg. int, float, double) need to be
aligned on word boundaries, eg. "int"s might need to be at addresses 0,
4, 8, .... (This is generally true on RISC machines).
An example might be:
#include <stdio.h>
int main()
{
char array[5];
int *i = array + 1;
*i = 7;
}
Here if array is 4 byte aligned, then i is off by 1; illegal on most
machines. Trying to write to it usually causes a bus error.
An example of overrunning an array might be:
#include <stdio.h>
int main()
{
char tinybuffer[5];
fgets(tinybuffer, 5000, stdin);
}
Where we are allowing someone to try to put 5000 characters in a 5
character buffer! This will usually give a segmentation fault
(SIGSEGV, 11).
HTH,
Rusty.
>
> Many thanks!
>
> Ted Sternberg
> San Jose, California, USA
>
> --
> Theodore Sternberg <str...@rahul.net>
--
Rusty....@adelaide.maptek.com.au "Engineer? So you drive trains?"
DO NOT BEND, FOLD OR MUTILATE IN ANY WAY THIS SCREEN. #include <stddisclm.h>