bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nasty consequence of fclose followed by ferror


From: Wolfram Gloger
Subject: Re: Nasty consequence of fclose followed by ferror
Date: Thu, 23 Nov 2000 11:19:59 +0100 ("MET)

Hello,

> I was porting code which is used on several OS's (freebsd, sunOS,
> solaris, aix, irix) to redhat linux 7.0, and ran into a number
> of odd bugs which were time-consuming to track down.
> 
> I eventually found that the basic cause for all those bugs was
> in the code I was porting.  It has:
>      fclose(fp);
>      if (ferror(fp)) { ... do stuff ... }
> 
> Please note I am quite happy to admit this code is wrong.

OK.

> However, for the sanity of other people who might run into
> this problem, I was wondering if there was some simple and
> inexpensive change which could be made to fclose or ferror
> which would make debugging this much less painful.

Have you tried running with MALLOC_CHECK_=2 set in the environment?
That is relatively inexpensive performance-wise and should usually
help to find the malloc'ed pointer that is `abused'.

If that doesn't help, bounds-checking gcc (recently added to
development snapshots of gcc) would very probably spotlight such a
problem fast.

Regards,
Wolfram.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]