public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <codonell@redhat.com>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [review v3] Remove all loaded objects if dlopen fails, ignoring NODELETE [BZ #20839]
Date: Mon, 02 Dec 2019 16:53:00 -0000	[thread overview]
Message-ID: <0c7fca0c-c087-23a2-3f1a-c7e7e4e6c588@redhat.com> (raw)
In-Reply-To: <871rtmyams.fsf@oldenburg2.str.redhat.com>

On 12/2/19 11:07 AM, Florian Weimer wrote:
> * Florian Weimer:
> 
>> +/* Mark the objects as NODELETE if required.  This is delayed until
>> +   after dlopen failure is not possible, so that _dl_close can clean
>> +   up objects if necessary.  */
>> +static void
>> +activate_nodelete (struct link_map *new, int mode)
>> +{
>> +  if (mode & RTLD_NODELETE || new->l_nodelete == link_map_nodelete_pending)
>> +    {
>> +      if (__glibc_unlikely (GLRO (dl_debug_mask) & DL_DEBUG_FILES))
>> +	_dl_debug_printf ("activating NODELETE for %s [%lu]\n",
>> +			  new->l_name, new->l_ns);
>> +      new->l_nodelete = link_map_nodelete_active;
>> +    }
>> +
>> +  for (unsigned int i = 0; i < new->l_searchlist.r_nlist; ++i)
>> +    {
>> +      struct link_map *imap = new->l_searchlist.r_list[i];
>> +      if (imap->l_nodelete == link_map_nodelete_pending)
>> +	{
>> +	  if (__glibc_unlikely (GLRO (dl_debug_mask) & DL_DEBUG_FILES))
>> +	    _dl_debug_printf ("activating NODELETE for %s [%lu]\n",
>> +			      imap->l_name, imap->l_ns);
>> +
>> +	  /* Only new objects should have set
>> +	     link_map_nodelete_pending.  Existing objects should not
>> +	     have gained any new dependencies and therefore cannot
>> +	     reach NODELETE status.  */
>> +	  assert (!imap->l_init_called || imap->l_type != lt_loaded);
> 
> This assert is incorrect because the NODELETE markers actually go in the
> other direction (from new loaded libraries to their dependencies).
> 
> I still need to write tests for this.  But I can submit a patch for the
> removal of the assert immediately, if so desired.

I'm happy with seeing two patches, one which fixes the regression for
Fedora Rawhide and OpenSUSE Tumbleweed, and another which expands the
testsuite coverage.

If I understood correctly it's because:

- A dlopen of libstdc++ ...
- Can be used by something else dlopen'd later with a STB_GNU_UNIQUE symbol...
- Causing libstdc++ to be marked NODLETE.

So libstdc++ is l_type == lt_loaded, and l_init_called == 1, which means bot
sides of the || are false.

-- 
Cheers,
Carlos.

  reply	other threads:[~2019-12-02 16:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-31 19:21 [review] " Florian Weimer (Code Review)
2019-10-31 20:18 ` Christian Häggström (Code Review)
2019-11-13 12:56 ` [review v2] " Florian Weimer (Code Review)
2019-11-13 14:28 ` Christian Häggström (Code Review)
2019-11-15 16:02 ` [review v3] " Florian Weimer (Code Review)
2019-12-02 16:07   ` Florian Weimer
2019-12-02 16:53     ` Carlos O'Donell [this message]
2019-11-21 12:57 ` Carlos O'Donell (Code Review)
2019-11-27 20:31 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-12-02 10:07   ` Szabolcs Nagy
2019-12-02 12:17     ` Florian Weimer
2019-12-02 13:52       ` Szabolcs Nagy

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=0c7fca0c-c087-23a2-3f1a-c7e7e4e6c588@redhat.com \
    --to=codonell@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@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).