Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Seg Faults in free() and fclose()

0 views
Skip to first unread message

Kristan Markey

unread,
Nov 21, 1998, 3:00:00 AM11/21/98
to
Hi,
I am attempting to get a program running which does a bit a input/output
and a small amount of work with arrays and matrices. However, the
program does not like certain free() and fclose() calls; it gives me
segmentation faults. The pointers are all cast and declared correctly,
they work sometimes, but as soon as one is fixed, another pops up later
in the program. In order to use some older code, I need to do pointer
arithmetic for consistent indicing.

Any suggestions would be appreciated as to why the seg faults occur or
how they can be controlled.
Thanks,
kristan


--
================================================================================
Kristan Markey k_ma...@coloradocollege.edu
WB #826 Barnes 323
Colorado Springs, CO 80946 Colorado College
(719) 389 7366 (719) 389 6746

Join me in supporting the thermodynmic death of the universe!
================================================================================


Paul Lutus

unread,
Nov 21, 1998, 3:00:00 AM11/21/98
to
Code?

Paul Lutus

Kristan Markey wrote in message <365777F2...@ColoradoCollege.edu>...

Jack Klein

unread,
Nov 23, 1998, 3:00:00 AM11/23/98
to
On Sat, 21 Nov 1998 19:33:23 -0700, Kristan Markey
<k_ma...@ColoradoCollege.edu> wrote:

> Hi,
> I am attempting to get a program running which does a bit a input/output
> and a small amount of work with arrays and matrices. However, the
> program does not like certain free() and fclose() calls; it gives me
> segmentation faults. The pointers are all cast and declared correctly,
> they work sometimes, but as soon as one is fixed, another pops up later
> in the program. In order to use some older code, I need to do pointer
> arithmetic for consistent indicing.
>
> Any suggestions would be appreciated as to why the seg faults occur or
> how they can be controlled.
> Thanks,
> kristan

<Jack>

You have memory problems in your code, most likely writing past the end of
allocated memory. This trashes the information maintained by the memory
allocation functions.

</Jack>


Peter Shaggy Haywood

unread,
Nov 27, 1998, 3:00:00 AM11/27/98
to
Groovy hepcat Kristan Markey was jivin' on Sat, 21 Nov 1998 19:33:23
-0700 in comp.programming.
Seg Faults in free() and fclose()'s a cool scene! Dig it!

>I am attempting to get a program running which does a bit a input/output
>and a small amount of work with arrays and matrices. However, the
>program does not like certain free() and fclose() calls; it gives me
>segmentation faults. The pointers are all cast and declared correctly,
>they work sometimes, but as soon as one is fixed, another pops up later
>in the program. In order to use some older code, I need to do pointer
>arithmetic for consistent indicing.

Show us the code. We can't say what could be happening with any
confidence if we don't know what you're doing. Having said that, I
might speculate the possibility that you have incremented a pointer
then passed that pointer to free(), or something like that.
--

----- Dig the EVEN NEWER, MORE IMPROVED news sig!! -----

-------------- Shaggy was here! ---------------
http://aardvark.apana.org.au/~phaywood/
============= Ain't I'm a dawg!! ==============


0 new messages