Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Richard Henderson <richard@atheist.tamu.edu>
Subject: Re: fclose()
Date: Mon, 24 Feb 1997 13:34:30 -0600 (CST)	[thread overview]
Message-ID: <199702241934.NAA19587@atheist.tamu.edu> (raw)
In-Reply-To: <33119E2E.7313@voicenet.com>

> The fclose() function conforms the the ANSI standard. No mention of a
> posix standard.
> 
> I suppose now I'll get a lecture on the virtues/history of ANSI, and
> Posix compliances ;-(

If you mean a lecture on how to read a standards document, yes.

Here's the excerpt from the ANSI standard:

] 7.9.3 Files
] 
]      [...]
] 
]      A file may be disassociated from a controlling stream by _closing_
]      the file.  Output streams are flushed (any unwritten buffers are
]      transmitted to the host environment) before the stream is
]      dissociated from the file.  The value of a pointer to a FILE object is
]      indeterminate after the associated file is closed (including the
]      standard text streams).

and from the ISO standard that supersedes it:

] The <tt/fclose/ function causes the stream pointed to by <tt/stream/
] to be flushed and the associated file to be closed.  Any unwritten
] data for the stream are delivered to the host environment to be
] written to the file; any unread data are discarded.  The stream is
] disassociated from the file.  If the associated buffer was
] automatically allocated, it is deallocated.

The ANSI document is a bit more explicit about stating that the 
state of the stream ("indeterminate"), but even the ISO version
gets there indirectly ("it is deallocated").

There will be no change to the current behavior of glibc.  I have
suggested before using a different malloc, you didn't like that.  I
also understand you can enable arena verification in malloc either 
by setting the environment variable MALLOC_CHECK_ or with

  mallopt(M_CHECK_ACTION, 1);

in your program.  This will prevent segv in the specific problem of
back-to-back frees, but will still fail under more complex conditions.
Expect a 20% performance hit for the extra verification.

I still urge you to go to the trouble to fix your program, as there
is no libc workaround that does not fail under some condition.  If you
don't want to do this, there's not much to be done.

r~

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

       reply	other threads:[~1997-02-24 19:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <33119E2E.7313@voicenet.com>
1997-02-24 19:34 ` Richard Henderson [this message]
1997-02-25 10:03 fclose() Uncle George
  -- strict thread matches above, loose matches on Subject: below --
1997-02-25  9:52 fclose() Uncle George
     [not found] <eric@brouhaha.com>
1997-02-25  4:08 ` fclose() Bryan W. Headley
1997-02-24 21:17 fclose() Craig Burley
1997-02-24 19:41 fclose() Eric Smith
1997-02-24 13:57 fclose() Uncle George
     [not found] <330AFE32.5C6E@voicenet.com>
1997-02-19 14:49 ` fclose() Richard Henderson
1997-02-19 17:45 ` fclose() Philip Blundell
1997-02-19 13:20 fclose() Uncle George
     [not found] <19970218191335.5758.qmail@brouhaha.com>
1997-02-18 22:32 ` fclose() D. Champion
1997-02-18 19:13 fclose() Eric Smith
1997-02-18 19:11 fclose() Mark Hamstra
1997-02-18 18:06 fclose() Uncle George
     [not found] <3309BA67.2168@voicenet.com>
1997-02-18 16:04 ` fclose() Richard Henderson
1997-02-18 14:19 fclose() Uncle George
     [not found] <richard@atheist.tamu.edu>
1997-02-17 19:47 ` fclose() Bryan W. Headley
1997-02-17 20:04   ` fclose() Richard Henderson
     [not found] <33088AF0.2FF1@voicenet.com>
1997-02-17 19:01 ` fclose() Richard Henderson
1997-02-17 16:44 fclose() Uncle George
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox