From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4116 invoked by alias); 16 Sep 2012 14:36:40 -0000 Received: (qmail 4107 invoked by uid 22791); 16 Sep 2012 14:36:39 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_CX X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 16 Sep 2012 14:36:24 +0000 From: "pedzsan at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/54601] New: AIX uses atexit which causes unloading of shared modules to break Date: Sun, 16 Sep 2012 14:36:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pedzsan at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-09/txt/msg01218.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54601 Bug #: 54601 Summary: AIX uses atexit which causes unloading of shared modules to break Classification: Unclassified Product: gcc Version: 4.5.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: pedzsan@gmail.com Created attachment 28200 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28200 git diff -c of base 4.5.2 tarball against new files and changes The bug was hit when using Apache httpd with a module called passenger. passenger uses some c++ code. httpd does an unload of all of the modules that it loads when it exits. The symptom is a core dump because by the time the atexit is run, the TOC entries as well as the code to execute which are registered as the DTORs have been unloaded. Using the x1.cpp attached, I determined that the atexit is used to register a DTOR for a static object with a non-trivial DTOR that is declared inside a function. The DTOR is registered only if the function is called. (x1.cpp does not demonstrate the problem. It was just used to educate me about when gcc used the atexit service.) I am also supplying a patch to the base 4.5.2 tarball that fixes the problem. I stole the cxa_atexit and cxa_finialize from GNU's glibc-2.16.0 implementation. I believe I have removed glibc's locking and successfully added back in the locking that gcc uses so that the file is built properly on the four different platforms: 32 bit, 32 bit threaded, 64 bit and 64 bit threaded. The changes to the configure and makefiles will need to be ported to the real files. I added references to the two new files introduced into the makefile and changed the configure script to assume cxa_atexit is present on AIX systems so that it will honor the --enable-__cxa_atexit configure option. The options I used for configure are: "--with-gmp=${PUBLIC_BASE}" \ "--with-mpfr=${PUBLIC_BASE}" \ "--with-mpc=${PUBLIC_BASE}" \ "--disable-nls" \ "--enable-threads=aix" \ "--with-libiconv-prefix=/usr" \ "--enable-__cxa_atexit" \ "--enable-languages=c,c++" If all goes well, I propose to have --enable-__cxa_atexit be the default for AIX. The final big change is to collect2. The changes are rather large. I tried to keep the proper style. There may be some debugging that can be removed. A new c stub is created in the first link pass so that __dso_handle can be declared to allow the first link to complete. I generalized a few things in the process. I hope all that is ok. I've used this new compiler for a month now but only on the original problem. All seems to be working.