Email List: Xaustin-group-lX
[All Lists]

atexit()

To: yyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: atexit()
From: Ulrich Drepper <yyyyyyy@xxxxxxxxxx>
Date: 26 Feb 2001 10:28:26 -0800
This is not a comment to the draft (it would have been if the review
wouldn't be closed) but should be discussed anyway.

One of the undefined behavior people constantly complain about to me
is using atexit() in dlopen()ed modules.  The Unix standard (the only
one combining atexit() and dlopen()) clearly says that the registered
functions are only executed "at normal program termination".
Obviously this doesn't work if the module in which atexit() was called
is unloaded using dlclose().  The standard does not require true
unloading (making the code unavailable) but it doesn't forbid it
either.

So the question is: which direction would/will the standard be changed
if I file a bug against the atexit() man page?

- allow atexit() in modules and require the destructor to be run at
  dlclose() time and then remove it from the list?  This is what most
  modern implementations seem to do (and I've just implemented this as
  well)

  This will require rewording in the man page to the extend of saying
  that normal program termination is not the only time the registered
  function is called and that the function is removed from the list.

- completely disallow the use of atexit() in dlopen() modules.  In this
  case the man page should say so and it would be necessary to add a new
  interface for this job.

- declare it implementation defined.

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

<Prev in Thread] Current Thread [Next in Thread>