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/30425] New: Symbol lookup during dlclose may fail unnecessarily
Date: Fri, 05 May 2023 20:31:35 +0000	[thread overview]
Message-ID: <bug-30425-131@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 30425
           Summary: Symbol lookup during dlclose may fail unnecessarily
           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: ---

Once an object is under removal, all its symbols become unavailable for symbol
resolution, due to this check in do_lookup_x:

      /* Do not look into objects which are going to be removed.  */
      if (map->l_removed)
        continue;

This can cause mysterious crashes during dlclose, particularly if function
symbols are weak due to GCC's C++ vague linkage implementation.

This (admittedly silly) patch fixes the downstream reproducer, but we should
add a C test case for this as well.

diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 05f36a2507..ecc1896c9d 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -366,8 +366,10 @@ do_lookup_x (const char *undef_name, unsigned int
new_hash,
       if ((type_class & ELF_RTYPE_CLASS_COPY) && map->l_type == lt_executable)
        continue;

-      /* Do not look into objects which are going to be removed.  */
-      if (map->l_removed)
+      /* Do not look into objects which are going to be removed.
+        References from a map that is under removal are allowed, to
+        enable lazy binding during dlclose.  */
+      if (map->l_removed && !undef_map->l_removed)
        continue;

       /* Print some debugging info if wanted.  */

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

             reply	other threads:[~2023-05-05 20:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 20:31 fweimer at redhat dot com [this message]
2023-05-05 20:34 ` [Bug dynamic-link/30425] " fweimer at redhat dot com
2023-05-21 14:24 ` fw at deneb dot enyo.de
2023-05-22 13:24 ` fweimer at redhat dot com
2023-06-05 16:09 ` 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-30425-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).