This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC] stdlib: Make atexit to not act as __cxa_atexit
* Adhemerval Zanella:
> For _dl_fini, we already have the link_map for object that calls
> __cxa_finalize. What we need is to filter out the exit handlers registered
> by the object itself, so its calls only the functions registered by the
> shared library referenced by the link_map.
>
> Not sure how easily we can accomplish it on exit handlers registration
> functions (the __dso_handler trick is to make this easier).
We can find the object that contains the address of __dso_handle, either
at registration time (perhaps better, to keep dlclose cost lower), or
during _dl_fini.
> The idea I am exploring is to change on how new handlers are included in
> the exit handler lists, so on a default execution (without handler adding
> new entries) atexit/on_exit are executed before __cxa_atexit.
Sorry, what do you mean? That *handlers* registered using
atexit/on_exit are executed before those registered via __cxa_atexit?
> The change is to make exit_function_list have an associated type which
> hold an only a specific set of handlers. Currently we required just
> two types, one for ef_at/ef_on handlers and one for ef_cxa. New inclusion
> are added in a ordered manner, where ef_at/ef_on are added on
> exit_function_list always before ef_cxa.
>
> Although on __cxa_finalize we will also need to explicit handle ef_at as
> well (for dlclose), the idea is also to mimic the ef_cxa behaviour and set
> the ef_at/ef_on free after its execution to avoid multiple executions
> (as a side note I think by not setting ef_on currently we might run on_exit
> handlers twice in some scenarios).
For dlclose, we also need to perform real deallocation at a certain
point, to avoid memory leaks.
Have you considered a design which puts the same handler entry on two
different lists?
Thanks,
Florian