unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* ELF destructor order vs constructor order
@ 2019-10-18 12:10 Florian Weimer
  0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2019-10-18 12:10 UTC (permalink / raw
  To: libc-alpha

Suppose that the constructors for object A run before the constructors
for object B.  (For the following, it does not matter how A and B were
loaded.)

Should it be possible that as the result of a dlclose call (or process
termination), the destructors for A also run before the destructors for
B?  Or should the destructors always run in the reverse order of
construction (assuming they happen during the same dlclose call)?

I think the answer should be that the reverse order is used.

We have a downstream report where a developer points out that they
perceive the destructor order more or less as random (in #1133521,
unfortunately not a public bug).  The reason is that the C++ compiler
tends to vary its emitted symbols with optimization settings and code
changes, and the dependencies recorded during lazy binding currently end
up changing the destructor order.

I think we should disregard the dynamic dependency information and
always perform the destructor calls in reverse order of the constructor
calls (for the objects that are about to be unloaded).

Comments?

Thanks,
Florian

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-10-18 12:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-18 12:10 ELF destructor order vs constructor order Florian Weimer

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