home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!munnari.oz.au!yarrina.connect.com.au!warrane.connect.com.au!g2syd!michaelh
- From: michaelh@g2syd.genasys.com.au (Michael Haldey)
- Subject: Re: Segmentation fault in malloc()
- Message-ID: <1993Jan21.033241.8461@g2syd.genasys.com.au>
- Organization: Genasys II, Sydney, Australia
- References: <2515@itexjct.jct.ac.il>
- Date: Thu, 21 Jan 1993 03:32:41 GMT
- Lines: 38
-
- In article <2515@itexjct.jct.ac.il> jacobsen@itexjct.jct.ac.il (Joel Jacobsen) writes:
- >
- > I wrote a program which use fgets to read a line from a file.
- >one of the functions get a segmentation fault in the line:
- >
- > fgets(str,160,file);
- >
- >when : char *str;
- > FILE *file;
- >
- >
- > The frame stack in gdb show:
- >
- > (gdb) where
- > #0 0xf7734634 in malloc ()
- > #1 0xf7733bf0 in _findbuf ()
- > #2 0xf773b86c in _filbuf ()
- > #3 0xf773df40 in fgets ()
- > #4 0x2288 in choose_from_list () at m.c:81
- >
- > .
- > .
- > .
- >
- >The system is: SparcStation 2 (64 Mb RAM)
- >The Unix is: Solaris 1
- >The Compiler is: Gcc
- >
- >
- > What might be the problem?
-
- Seems that you haven't malloc-ed enough memory for your 'str' buffer.
-
- michael
- --
- Michael Haldey | Genasys II Pty Ltd, Sydney, Australia
- | Phone: +61-2-954-2878 (-9930 FAX)
- | Internet: michaelh@g2syd.genasys.com.au
-