Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Re: fclose()
@ 1997-02-24 13:57 Uncle George
  0 siblings, 0 replies; 20+ messages in thread
From: Uncle George @ 1997-02-24 13:57 UTC (permalink / raw)


I just looked at the Linux man pages for fclose(). I shudda looked at
them at the beginning of this dialog, but interestingly enough THAT
DOCUMENTATION seems to support my view point -under ERRORS:

	 EBADF the argument stream is not an open stream.

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 ;-(

-- 
Uncle George ( aka G. Baeslack )
http://www.voicenet.com/~gatgul

--
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

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: fclose()
@ 1997-02-25 10:03 Uncle George
  0 siblings, 0 replies; 20+ messages in thread
From: Uncle George @ 1997-02-25 10:03 UTC (permalink / raw)


Craig Burley wrote:
>
> a waste of time for people, like myself, who don't want to
> read about those who can't take the time to write correct
> code and want everybody else's programs slowed down to
> compensate.
> 
>         tq vm, (burley)
> 
I suppose u are right:

	Seat Belts are useless,
	air-bags are useless
	crash impact bumpers are useless,
	roll bars are useless,
	and so on

	These features waste a lot of money, time, lives, and slow down
everyone because of a few people who cannot compensate.

Just as a side note - Its not my program.

-- 
Uncle George ( aka G. Baeslack )
http://www.voicenet.com/~gatgul

--
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

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: fclose()
@ 1997-02-25  9:52 Uncle George
  0 siblings, 0 replies; 20+ messages in thread
From: Uncle George @ 1997-02-25  9:52 UTC (permalink / raw)


Richard Henderson wrote:
> 
> 
> 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~
The Program Is not in my care - I am just a (l)user of a seg-fault.
your diatribe on fclose() does not mention error codes. Anyway the doc I
refered to is from the Linux Man pages on my alpha/axp. Maybe not up to
date, but apparently a viable reference to the prob at hand!

-- 
Uncle George ( aka G. Baeslack )
http://www.voicenet.com/~gatgul

--
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

^ permalink raw reply	[flat|nested] 20+ messages in thread
[parent not found: <eric@brouhaha.com>]
* Re: fclose()
@ 1997-02-24 21:17 Craig Burley
  0 siblings, 0 replies; 20+ messages in thread
From: Craig Burley @ 1997-02-24 21:17 UTC (permalink / raw)


>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.

In any case, this discussion should probably be moved off of
axp-list.  It long ago became fairly irrelevant to the issue
of making stuff work on DEC Alpha machines, becoming instead
a waste of time for people, like myself, who don't want to
read about those who can't take the time to write correct
code and want everybody else's programs slowed down to
compensate.

        tq vm, (burley)

--
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

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: fclose()
@ 1997-02-24 19:41 Eric Smith
  0 siblings, 0 replies; 20+ messages in thread
From: Eric Smith @ 1997-02-24 19:41 UTC (permalink / raw)


Uncle George <gatgul@voicenet.com> wrote:
> I just looked at the Linux man pages for fclose(). I shudda looked at
> them at the beginning of this dialog, but interestingly enough THAT
> DOCUMENTATION seems to support my view point -under ERRORS:
> 	 EBADF the argument stream is not an open stream.

Yes, but even if it did that, you *still* wouldn't be safe calling fclose()
twice on the same stream.  Why?  Because it would still be possible that
an intermediate open() call might have returned the same pointer:

	f1 = fopen ("foo", "r");  /* returns 28 */
	fclose (f1);
	f2 = fopen ("bar", "r");  /* also returns 28 */
	fclose (f1);              /* oops!  28 is still a valid stream! */
	fprintf (f2, "test\n");   /* fails */

Cheers,
Eric

--
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

^ permalink raw reply	[flat|nested] 20+ messages in thread
[parent not found: <33119E2E.7313@voicenet.com>]
[parent not found: <330AFE32.5C6E@voicenet.com>]
* Re: fclose()
@ 1997-02-19 13:20 Uncle George
  0 siblings, 0 replies; 20+ messages in thread
From: Uncle George @ 1997-02-19 13:20 UTC (permalink / raw)


Mark Hamstra wrote:
 
> The only error POSIX compliant fclose() can return is EOF, which is not
> appropriate in the case of this type of programmer error. 
I suppose it would be asking too much to have

	if ( chan not open )
		return ( EOF );

as part of the fclose() process. I suppose EOF means anything you want
it to mean ( Alice in Wonderland? ).

So who do I really vent this fustration upon? POSIX? GNU? axp ( axp - if
i really look at the code and see that something is not working ) ?

-- 
Uncle George ( aka G. Baeslack )
http://www.voicenet.com/~gatgul

--
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

^ permalink raw reply	[flat|nested] 20+ messages in thread
[parent not found: <19970218191335.5758.qmail@brouhaha.com>]
* Re: fclose()
@ 1997-02-18 19:13 Eric Smith
  0 siblings, 0 replies; 20+ messages in thread
From: Eric Smith @ 1997-02-18 19:13 UTC (permalink / raw)


Uncle George <gatgul@voicenet.com> wrote:
> actually my point wudda have been the the primitive os calls
> open/close behave in predictable ways.

The primitive OS calls open() and close() do behave in predictable ways.  If
you call close() on an FD that isn't open, it will return an error.

fclose() isn't a primitive OS call.

> the first close() I would get a return of 0;
> the second close() I would, and expect a return of -1 with errno set.
> I do not expect an system crash to happen.

A system crash does not happen.  The process is sent a signal and exits.

> I expect fclose to give me an error return - something more gracefull than a
> segfault. Fclose should know that the ptr is invalid - points to no open
> channel - and give an appropiate error code.

What's the point in checking the return code or errno for fclose()?  What
are you going to do if it fails, try to close it again, hoping that the error
condition has been remedied?  Print "Abort, Retry, Ignore?" to stderr?  :-)

Cheers,
Eric

--
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

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: fclose()
@ 1997-02-18 19:11 Mark Hamstra
  0 siblings, 0 replies; 20+ messages in thread
From: Mark Hamstra @ 1997-02-18 19:11 UTC (permalink / raw)


On Tue, 18 Feb 1997, Uncle George wrote:

> I can only say that the analogy is the same with fclose(). I expect
> fclose to give me an error return - something more gracefull than a
> segfault. Fclose should know that the ptr is invalid - points to no open
> channel - and give an appropiate error code.

The only error POSIX compliant fclose() can return is EOF, which is not
appropriate in the case of this type of programmer error.  I suppose you
could make a case that your compiler should return a warning or error, but
to change fclose() to return what you think is an appropriate error at
runtime is at least as wrong as depending upon what is specified as
undefined behaviour.

Mark Hamstra
Bentley Systems, Inc.

--
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

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: fclose()
@ 1997-02-18 18:06 Uncle George
  0 siblings, 0 replies; 20+ messages in thread
From: Uncle George @ 1997-02-18 18:06 UTC (permalink / raw)


> However, I also don't really understand that you'd rather the system
> hid from you errors in your program that can do just as bizzare
> undefined things on other systems, as Jim Nance pointed out for SunOS.

actually my point wudda have been the the primitive os calls
open/close behave in predictable ways.
the first close() I would get a return of 0;
the second close() I would, and expect a return of -1 with errno set.
I do not expect an system crash to happen. If a system crash does
happen, according to this discussion, it is not the fault of the system
designer, but rather the fault of the poor victum, who has stumbled on
to the failing condition. Who is at fault - they both are. Who should be
more responsible - The OS designer - that person knows, or should know
that things like that are bound to happen.
I can only say that the analogy is the same with fclose(). I expect
fclose to give me an error return - something more gracefull than a
segfault. Fclose should know that the ptr is invalid - points to no open
channel - and give an appropiate error code.

Uncle George ( aka G. Baeslack )
http://www.voicenet.com/~gatgul

--
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

^ permalink raw reply	[flat|nested] 20+ messages in thread
[parent not found: <3309BA67.2168@voicenet.com>]
* Re: fclose()
@ 1997-02-18 14:19 Uncle George
  0 siblings, 0 replies; 20+ messages in thread
From: Uncle George @ 1997-02-18 14:19 UTC (permalink / raw)


Richard Henderson wrote:
> 
> >               fclose(fchan);          /* works        */
> >               fclose(fchan);          /* segfaults    */
> 
> Yep.  malloc doen't like it when you free the same pointer twice.
> 
That may be nice to blame malloc, but it should not have gotten that far
- the channel is closed!!! fclose should be returning an error. A
segfault is not appropriate under any circumstances

	fd = open();
	close(fd);		/* system allows it	*/
	close(fd);		/* OS Paniks-is this what u want!!*/
				/* Or acceptable?	*/

> > Ok, so Who's in charge of this code, so I relay my findings?
> 
> Me, I guess.  This is a known occurrence.  The bug, though,
> is with the program trying to fclose twice.  The solution of
> course is not to do that.
that is one bug, the other is of course the segfault.This didn't happen
under the static lib's in 3.0.3 - only occured in the redhat 4 series

gat

--
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

^ permalink raw reply	[flat|nested] 20+ messages in thread
[parent not found: <richard@atheist.tamu.edu>]
[parent not found: <33088AF0.2FF1@voicenet.com>]
* fclose()
@ 1997-02-17 16:44 Uncle George
  0 siblings, 0 replies; 20+ messages in thread
From: Uncle George @ 1997-02-17 16:44 UTC (permalink / raw)


ever since I upgraded to 4.0/4.1 the pgm called 'suck' has crashed with
a seg fault.

I finally got fed up( gdb/xxgdb doesn't exactly work well with stack
traces!) , and tracked it down to an fclose() call. 

	ie:	fchan = fopen();	/* works	*/
		fclose(fchan);		/* works	*/
		fclose(fchan);		/* segfaults	*/

I suppose that there are other pgms that potentially follow this
process, and maybe there would be a fclose() that recognises a bogus
pointer/close channel.

Ok, so Who's in charge of this code, so I relay my findings?

-- 
Uncle George ( aka G. Baeslack )
http://www.voicenet.com/~gatgul

--
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

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~1997-02-25 10:03 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-02-24 13:57 fclose() Uncle George
  -- strict thread matches above, loose matches on Subject: below --
1997-02-25 10:03 fclose() Uncle George
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
     [not found] <33119E2E.7313@voicenet.com>
1997-02-24 19:34 ` fclose() Richard Henderson
     [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

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