From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9994 invoked by alias); 2 Apr 2014 09:49:17 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 9954 invoked by uid 48); 2 Apr 2014 09:49:13 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/60731] [4.7/4.8/4.9 Regression] dynamic library not getting reinitialized on multiple calls to dlopen() Date: Wed, 02 Apr 2014 09:49:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-04/txt/msg00133.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60731 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #2 from Richard Biener --- 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?