This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [review v3] Remove all loaded objects if dlopen fails, ignoring NODELETE [BZ #20839]
- From: Florian Weimer <fweimer at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Mon, 02 Dec 2019 17:07:07 +0100
- Subject: Re: [review v3] Remove all loaded objects if dlopen fails, ignoring NODELETE [BZ #20839]
- References: <gerrit.1572549639000.Ib2a3d86af6f92d75baca65431d74783ee0dbc292@gnutoolchain-gerrit.osci.io> <20191115160205.9EEC928171@gnutoolchain-gerrit.osci.io>
* 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.
Thanks,
Florian