home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / solaris / 217 < prev    next >
Encoding:
Internet Message Format  |  1992-09-15  |  1.9 KB

  1. Xref: sparky comp.unix.solaris:217 comp.unix.programmer:4675 comp.unix.wizards:3920
  2. Path: sparky!uunet!sun-barr!ames!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!wupost!think.com!linus!philabs!trotter!zj8549
  3. From: zj8549@trotter.usma.edu (Junod John MSG)
  4. Newsgroups: comp.unix.solaris,comp.unix.programmer,comp.unix.wizards
  5. Subject: Segmentation faults on sun4 platforms
  6. Message-ID: <1423@trotter.usma.edu>
  7. Date: 15 Sep 92 22:36:33 GMT
  8. Followup-To: poster
  9. Organization: US Military Academy, West Point, NY
  10. Lines: 46
  11.  
  12. Can't seem to figure this one out.  We are porting some code to a 
  13. sun4 platform, specifically a Sparc 2 and Sparc IPC, from System V.
  14. Its SunOS 4.1.
  15.  
  16. I keep getting "segmentation faults" from the following code extracts.
  17. There is considerably more code and multiple source files.  The end
  18. of routine2 correctly prints the contents of buf, but buf is a null
  19. pointer after the return from routine2.
  20.  
  21. Can someone please help point out the error of my ways?  Is there some
  22. way to increase stack size (or heap size or whatever)?  Or am I way
  23. off track?
  24.  
  25. routine() {
  26.    char buf[256];
  27.    int retcode;
  28.    strcpy(buf,"initialized");
  29.    retcode=routine1(buf);
  30.    ....
  31. }
  32. routine1(buf) char *buf; {
  33.    char buf1[256];
  34.    int retcode;
  35.    ......
  36.    puts(buf);          /* prints ok */
  37.    retcode=routine2(buf);
  38.    puts(buf);          /* prints NULL */
  39.    strcpy(buf1,buf);   /* segmentation fault */ 
  40.    .....
  41.    return retcode;
  42. }
  43. routine2(buf) char *buf; {
  44.    int retcode;
  45.    ......
  46.    puts(buf);          /* prints ok */
  47.    /* modify contents of buf */
  48.    puts(buf);          /* prints ok */
  49.    return retcode;
  50. }
  51.  
  52. THANKS IN ADVANCE!
  53. ------------------------------------------------------------------------------
  54. MSG John Junod <zj8549@trotter.usma.edu>    <postmaster@trotter.usma.edu>
  55. Chief, Academic Network Engineering Branch         
  56. United States Military Academy, West Point NY 10996
  57. Phone: (914)-938-5038/9 or AV: 688-5038/9
  58.