home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.solaris:217 comp.unix.programmer:4675 comp.unix.wizards:3920
- Path: sparky!uunet!sun-barr!ames!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!wupost!think.com!linus!philabs!trotter!zj8549
- From: zj8549@trotter.usma.edu (Junod John MSG)
- Newsgroups: comp.unix.solaris,comp.unix.programmer,comp.unix.wizards
- Subject: Segmentation faults on sun4 platforms
- Message-ID: <1423@trotter.usma.edu>
- Date: 15 Sep 92 22:36:33 GMT
- Followup-To: poster
- Organization: US Military Academy, West Point, NY
- Lines: 46
-
- Can't seem to figure this one out. We are porting some code to a
- sun4 platform, specifically a Sparc 2 and Sparc IPC, from System V.
- Its SunOS 4.1.
-
- I keep getting "segmentation faults" from the following code extracts.
- There is considerably more code and multiple source files. The end
- of routine2 correctly prints the contents of buf, but buf is a null
- pointer after the return from routine2.
-
- Can someone please help point out the error of my ways? Is there some
- way to increase stack size (or heap size or whatever)? Or am I way
- off track?
-
- routine() {
- char buf[256];
- int retcode;
- strcpy(buf,"initialized");
- retcode=routine1(buf);
- ....
- }
- routine1(buf) char *buf; {
- char buf1[256];
- int retcode;
- ......
- puts(buf); /* prints ok */
- retcode=routine2(buf);
- puts(buf); /* prints NULL */
- strcpy(buf1,buf); /* segmentation fault */
- .....
- return retcode;
- }
- routine2(buf) char *buf; {
- int retcode;
- ......
- puts(buf); /* prints ok */
- /* modify contents of buf */
- puts(buf); /* prints ok */
- return retcode;
- }
-
- THANKS IN ADVANCE!
- ------------------------------------------------------------------------------
- MSG John Junod <zj8549@trotter.usma.edu> <postmaster@trotter.usma.edu>
- Chief, Academic Network Engineering Branch
- United States Military Academy, West Point NY 10996
- Phone: (914)-938-5038/9 or AV: 688-5038/9
-