Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Dec 2002 17:56:02 -0800
From:      Alfred Perlstein <bright@mu.org>
To:        Mikhail Teterin <mi@corbulon.video-collage.com>
Cc:        arch@FreeBSD.org, riggs@rrr.de
Subject:   Re: atexit(3), exit(3) vs. dlclose(3) et al
Message-ID:  <20021207015602.GT58155@elvis.mu.org>
In-Reply-To: <200212062321.gB6NLcEt052452@corbulon.video-collage.com>
References:  <200212062321.gB6NLcEt052452@corbulon.video-collage.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* Mikhail Teterin <mi@corbulon.video-collage.com> [021206 15:21] wrote:
> Hello!
> 
> I've just reported what seems to be a bug in mplayer, but am still
> wondering, why it existed for so long.
> 
> Mplayer was crashing in exit(3) (a silly place to crash, is not it?).

A cursory glance at glibc seems to indicate that they do call the
atexit() callback at module unload time.

the way they seem to do this is by declaring (in thier atexit.c):

  /* This is defined by newer gcc version unique for each module.  */
  extern void *__dso_handle __attribute__ ((__weak__));

Then doing this:

/* Register FUNC to be executed by `exit'.  */
int
atexit (void (*func) (void))
{
  return __cxa_atexit ((void (*) (void *)) func, NULL,
                       &__dso_handle == NULL ? NULL : __dso_handle);
}

I'm sort of busy, but I'm guessing that dlopen(3) fills in __dso_handle
for them and then __cxa_atexit uses some call to link the at_exit
callback to the dso's list to be called at dlclose.

It would be nice to know if this is a feature we need to support and/or
is even correct.  Basically if the standard says "undefined" on this
sort of behaviour then we're free to crash, otherwise we ought to do
something about it.

-Alfred

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021207015602.GT58155>