The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Operating Systems > HP-UX
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-05-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
Here is a quick program:

Code:
#ifdef __STDC__
#define PROTOTYPICAL
#endif
#ifdef __cplusplus
#define PROTOTYPICAL
#endif

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>


#ifdef PROTOTYPICAL
int main(int argc, char *argv[])
#else
main(argc,argv)
char *argv[];
#endif
{
        char *p;
        brk(&p);
        *--p=1;
        exit(0);
}

It is specific to HP-UX. But copy that code into a file called memoryfault.c. Compile it with:
cc memoryfault.c -o memoryfault
and run it with:
./memoryfault

It will generate a memory fault. This is because it attempted a illegal sequence of operations. Adding memory or swap to your box will not fix my program. My program is broken. That's what a memory fault is.

A "memory fault" might be called a "segmentation fault" on another OS. Or even another shell. But the signal SIGSEGV was sent to process by the kernel. The shell detects this and displays the "memory fault" message.

Basicly the program attempted to write into a place that was not a writable memory segment. Your program might be doing that. Or it might be attempting a read from a location that is not in a readable memory segment.

But clearly, the program has a bug and it almost certainly involves referencing a pointer with an invalid value. And the author of the program is going to need to fix that.