public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Robert Lipe <robertl@dgii.com>
To: acs@acm.org, egcs@cygnus.com, gcc2@cygnus.com, rr@sco.com
Subject: Re: egcs 10-31 and UnixWare
Date: Mon, 10 Nov 1997 14:57:00 -0000	[thread overview]
Message-ID: <19971110134955.60772@dgii.com> (raw)
In-Reply-To: <m0xUzRe-0004ecC@ocean.lucon.org>

[ Re: Program calling exit() in a function registered via atexit() ] 

I asked one of the SCO engineers about this, and he confirms the 
behaviour is as we suspected, though it is changed in future versions.

He offered:

	Regarding the standard, the behavior is undefined when a
	program calls exit() from an atexit()-registered function:

		"If more than one call to the exit function is
		 executed by a program, the behavior is undefined."

	in the description of exit in the current C standard.

I don't see this in my copy of Plauger's C library spec or in 
SUSv2, but it's certainly believable.

> > Redhat 4.1/x86: Calls two.   Calls one.  Calls two.  Call two.  Repeats
> > 	until stack size hits 8Mb ulimit.  Faults.
> 
> I got the same result as Linux on Windows NT 4.0 with VC++ 5.0.
> However I can change Linux to whatever behaviorw which makes
> more senses.
> 
> How about call everyone on the list and use the status in the
> last exit () call? BTW, it seems to be what happens on Solaris.

I'll leave that to you, H.J.  

I think the OpenServer (which calls abort() in this case, grrr..)
option is to remove HAVE_ATEXIT from sco5.h and let the dtors be 
run via .fini instead of via an exit callback.   This I did in my
recent patch to gcc2 and egcs.  


Alternately, should we discourage (disallow?) calling exit()
from destructors?    If so, just changing the exit() in the
testcase in question to _exit() would sidestep the issue for
the testcase, thought it might still be an issue for the Real 
World.   Of course, if Linux and the other two OSes that H.J.
cited are indicative of the Real World, nobody does this 
anyway....

It seems like loophole to restrain global destructors based on
undefined behaviour in atexit() when the programmer didn't call
atexit() - we used atexit() behind his back.

From here, the language lawyers in the group can duke it out. :-)

RJL

  reply	other threads:[~1997-11-10 14:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-11-07  9:25 acs
1997-11-09 10:14 ` Jeffrey A Law
1997-11-09 11:16   ` Robert Lipe
1997-11-09 13:49     ` Jeffrey A Law
1997-11-09 12:35       ` acs
1997-11-09 13:00       ` Robert Lipe
1997-11-09 17:00         ` Jeffrey A Law
1997-11-09 18:35           ` Joe Buck
1997-11-09 21:08             ` Joern Rennecke
1997-11-09 20:32           ` Robert Lipe
1997-11-10 14:57             ` H.J. Lu
1997-11-10 14:57               ` Robert Lipe [this message]
1997-11-10 12:27                 ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19971110134955.60772@dgii.com \
    --to=robertl@dgii.com \
    --cc=acs@acm.org \
    --cc=egcs@cygnus.com \
    --cc=gcc2@cygnus.com \
    --cc=rr@sco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).