From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16236 invoked by alias); 23 Apr 2014 09:09:26 -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 16192 invoked by uid 48); 23 Apr 2014 09:09:23 -0000 From: "neleai at seznam dot cz" 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, 23 Apr 2014 09:09: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: neleai at seznam dot cz X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jason 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/msg01686.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60731 Ondrej Bilka changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |neleai at seznam dot cz --- Comment #9 from Ondrej Bilka --- I started to looking what STB_UNIQUE purpose is so I have several questions. First does suggestion below really work? http://gcc.gnu.org/ml/gcc-help/2011-05/msg00450.html Say you have foo.so with unique symbol foo and function bar *getfoo() { return (void *) &foo; } which gets loaded and unloaded like void *h = dlopen("foo.so",RTLD_NOW); bar *p1 = dlsym(h,"getfoo")(); dlclose(h); foo->baz(); h = dlopen("foo.so",RTLD_NOW); bar *p2 = dlsym(h,"getfoo")(); dlclose(h); Are p1 and p2 supposed to point to same object? Also is foo->baz(); legal or not? If its so we cannot call destructors. There could be fix to add zombie state where we call destructors but not free memory so we can reinitialize object at same address but I need to know that calling destructor is always intended behaviour.