public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "fweimer at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug dynamic-link/30869] New: Fine-tune ELF destructor ordering
Date: Tue, 19 Sep 2023 06:38:28 +0000	[thread overview]
Message-ID: <bug-30869-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=30869

            Bug ID: 30869
           Summary: Fine-tune ELF destructor ordering
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: fweimer at redhat dot com
  Target Milestone: ---

The change in bug 30785 to use reverse constructor orders for destructors does
not match expectations of existing applications when objects are destructed by
_dl_fini.

In particular, the destructors for the main program need to run first. This may
trigger additional destructor invocations if dlclose is called. After the main
program, the initially loaded objects should be destroyed, potentially
triggering more dlclose calls. Only after that, the remaining dlopen'ed objects
should be destroyed. This way, applications have some control over destructor
ordering through there dlclose calls, which seems useful.

A similar issue occurs if dlopen is called from ELF constructors: The current
code schedules an object for later destruction *before* it invokes ELF
constructors. This means that dlopen'ed objects from ELF constructors may be
destructed first, even if the original object calling dlopen might want to
close these objects by calling dlclose from its destructor.

These changes mostly apply to _dl_fini because when dlclose calls ELF
destructors, explicitly dlopen'ed objects (from ELF constructors etc.) still
have incremented direct-open counters, and they only become eligible for
destruction if invoked ELF destructors invoke dlclose.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2023-09-19  6:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19  6:38 fweimer at redhat dot com [this message]
2023-09-19  6:38 ` [Bug dynamic-link/30869] " fweimer at redhat dot com
2023-09-19  7:36 ` fweimer at redhat dot com
2023-09-19  7:36 ` fweimer at redhat dot com
2023-09-19 11:53 ` fweimer at redhat dot com
2023-10-18 14:30 ` fweimer at redhat dot com

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=bug-30869-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /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).