[Bug c++/60731] [4.7/4.8/4.9 Regression] dynamic library not getting reinitialized on multiple calls to dlopen()

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Apr 2 09:49:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60731

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
We hit

void
_dl_close (void *_map)
{
  struct link_map *map = _map;

  /* First see whether we can remove the object at all.  */
  if (__builtin_expect (map->l_flags_1 & DF_1_NODELETE, 0))
    {
      assert (map->l_init_called);
      /* Nope.  Do nothing.  */
      return;

the DF_1_NODELETE flag is set already after the first dlopen call which sets
it via do_lookup_x for the STB_GNU_UNIQUE symbol _ZGVZ16make_static_stayvE3smp

                  if (map->l_type == lt_loaded)
                    /* Make sure we don't unload this object by
                       setting the appropriate flag.  */
                    ((struct link_map *) map)->l_flags_1 |= DF_1_NODELETE;

so this either points to a "bad" design on the guard code for initializing
'smp' or to a weakness in the dynamic loader which doesn't handle unloading
of objects which define any(?) STB_GNU_UNIQUE symbol.  Note the above is
guarded with

              if ((type_class & ELF_RTYPE_CLASS_COPY) != 0)
                enter (entries, size, new_hash, strtab + sym->st_name, ref,
                       undef_map);
              else
                {
                  enter (entries, size, new_hash, strtab + sym->st_name, sym,
                         map);

                  if (map->l_type == lt_loaded)
                    /* Make sure we don't unload this object by
                       setting the appropriate flag.  */
                    ((struct link_map *) map)->l_flags_1 |= DF_1_NODELETE;
                }

thus if this were referenced via a copy relocation it would work.

Jason?



More information about the Gcc-bugs mailing list