[comp.unix.programmer] HELP! Why do I get error message: "Segmentation fault

rstanton@leland.Stanford.EDU (Richard Stanton) (05/23/91)

The following may be simple, but I'm new to the AIX environment (and to 
programming in C under any UNIX).

I am trying to run a large C program on an IBM RS/6000. The program has
run fine on a VAX, but when I try to run it on the IBM, it starts OK, but
after a certain point I get the error message:

"Segmentation fault(coredump)"

This appears to happen at a section of code where memory is being allocated
using calloc, but I test for failure here, and my own error message is never
produced. What does this error message mean, and what do I have to do to
get the program to run properly?

Another program dies at a similar point, but this time it tells me it can't
allocate the memory I asked for using my own error message. How can I increase
the amount of memory available to the program?

Thanks for any help you can give me.

Richard Stanton
pstanton@gsb-lira.stanford.edu

s902113@minyos.xx.rmit.oz.au (Luke Mewburn) (05/24/91)

rstanton@leland.Stanford.EDU (Richard Stanton) writes:

>The following may be simple, but I'm new to the AIX environment (and to 
>programming in C under any UNIX).

>I am trying to run a large C program on an IBM RS/6000. The program has
>run fine on a VAX, but when I try to run it on the IBM, it starts OK, but
>after a certain point I get the error message:

>"Segmentation fault(coredump)"

>This appears to happen at a section of code where memory is being allocated
>using calloc, but I test for failure here, and my own error message is never
>produced. What does this error message mean, and what do I have to do to
>get the program to run properly?

Well, I had a similar problem recently, but not the same (although, since
you mention the use of 'calloc', the problems are probably related :-)
Anyway, make sure  that you are not doing something alongs the lines of
this:
malloc/calloc x bytes. Use x bytes __+1__ (I did this by allocating 20
bytes, and strcpying 20. The \0 overwrote the next block).
Anyway, the malloc table info might be getting corrupted, so you are
getting incorrect malloc results and/or seg. faults

>Another program dies at a similar point, but this time it tells me it can't
>allocate the memory I asked for using my own error message. How can I increase
>the amount of memory available to the program?

>Thanks for any help you can give me.

>Richard Stanton
>pstanton@gsb-lira.stanford.edu
-- 
____________________________________________________________________________
|                                     |                                    |
| Luke Mewburn   (Zak)                |      This side for lease...        |
| s902113@minyos.xx.rmit.oz.au        | (No disclaimer, can't afford it:-) |

andy@research.canon.oz.au (Andy Newman) (05/25/91)

rstanton@leland.Stanford.EDU (Richard Stanton) writes:
>The following may be simple, but I'm new to the AIX environment (and to 
>programming in C under any UNIX).
>
>I am trying to run a large C program on an IBM RS/6000. The program has
>run fine on a VAX, but when I try to run it on the IBM, it starts OK, but
>after a certain point I get the error message:
>
>"Segmentation fault(coredump)"
>

Sounds like a NULL pointer dereference. VAXen have data at location 0
many modern systems don't (is AIX in this league?).
-- 
Andy Newman (andy@research.canon.oz.au) Canon Info. Systems Research Australia

hbergh@nlicl1.oracle.com (Herbert van den Bergh) (05/27/91)

In article <1991May25.055311.8071@research.canon.oz.au>, andy@research.canon.oz.au (Andy Newman) writes:
|> Sounds like a NULL pointer dereference. VAXen have data at location 0
|> many modern systems don't (is AIX in this league?).

	Nope. From /usr/lpp/bos/bsdport:

   7.1.  Derefencing NULL Pointers

      The word at memory location zero contains a  zero.
      That  means  that  code which has been incorrectly
      written to use a NULL pointer to represent a  null
      string  will  work,  but  will  not be portable to
      other UNIX operating systems, and may not work  on
      future AIX systems.

|> -- 
|> Andy Newman (andy@research.canon.oz.au) Canon Info. Systems Research Australia

-- 
	Regards,

	Herbert van den Bergh                    hbergh@oracle.com
	Oracle Europe                            or uunet!oracle!hbergh

bhoughto@pima.intel.com (Blair P. Houghton) (05/28/91)

In article <1406@nlsun1.oracle.nl> hbergh@oracle.com writes:
-In article <1991May25.055311.8071@research.canon.oz.au>, andy@research.canon.oz.au (Andy Newman) writes:
-|> Sounds like a NULL pointer dereference. VAXen have data at location 0
-|> many modern systems don't (is AIX in this league?).
-
-	Nope. From /usr/lpp/bos/bsdport:
-
-   7.1.  Derefencing NULL Pointers
-
-      The word at memory location zero contains a  zero.
-      That  means  that  code which has been incorrectly
-      written to use a NULL pointer to represent a  null
-      string  will  work,  but  will  not be portable to
-      other UNIX operating systems, and may not work  on
-      future AIX systems.

I may vomit.

People who don't understand programming languages have no
business writing compilers.

				--Blair
				  "Some days it doesn't pay to let the
				   monkeys back on their typewriters..."