home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / question / 15783 next >
Encoding:
Text File  |  1993-01-21  |  1.3 KB  |  49 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!munnari.oz.au!yarrina.connect.com.au!warrane.connect.com.au!g2syd!michaelh
  3. From: michaelh@g2syd.genasys.com.au (Michael Haldey)
  4. Subject: Re: Segmentation fault in malloc()
  5. Message-ID: <1993Jan21.033241.8461@g2syd.genasys.com.au>
  6. Organization: Genasys II, Sydney, Australia
  7. References: <2515@itexjct.jct.ac.il>
  8. Date: Thu, 21 Jan 1993 03:32:41 GMT
  9. Lines: 38
  10.  
  11. In article <2515@itexjct.jct.ac.il> jacobsen@itexjct.jct.ac.il (Joel Jacobsen) writes:
  12. >
  13. > I wrote a program which use fgets to read a line from a file.
  14. >one of the functions get a segmentation fault in the line:
  15. >
  16. >    fgets(str,160,file);
  17. >
  18. >when :  char *str;
  19. >        FILE *file;
  20. >
  21. >
  22. > The frame stack in gdb show:
  23. >
  24. >    (gdb) where
  25. >    #0 0xf7734634 in malloc ()
  26. >    #1 0xf7733bf0 in _findbuf ()
  27. >    #2 0xf773b86c in _filbuf ()
  28. >    #3 0xf773df40 in fgets ()
  29. >    #4 0x2288 in choose_from_list () at m.c:81
  30. >
  31. >            .
  32. >            .
  33. >            .
  34. >
  35. >The system is:   SparcStation 2 (64 Mb RAM)
  36. >The Unix is:     Solaris 1
  37. >The Compiler is: Gcc
  38. >
  39. >
  40. > What might be the problem?
  41.  
  42. Seems that you haven't malloc-ed enough memory for your 'str' buffer.
  43.  
  44. michael
  45. -- 
  46. Michael Haldey  |  Genasys II Pty Ltd, Sydney, Australia
  47.                 |  Phone:    +61-2-954-2878 (-9930 FAX)
  48.                 |  Internet: michaelh@g2syd.genasys.com.au
  49.