public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54601] New: AIX uses atexit which causes unloading of shared modules to break
@ 2012-09-16 14:36 pedzsan at gmail dot com
  2012-09-16 14:39 ` [Bug c++/54601] " pedzsan at gmail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: pedzsan at gmail dot com @ 2012-09-16 14:36 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-02-01 20:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-16 14:36 [Bug c++/54601] New: AIX uses atexit which causes unloading of shared modules to break pedzsan at gmail dot com
2012-09-16 14:39 ` [Bug c++/54601] " pedzsan at gmail dot com
2012-09-16 14:40 ` pedzsan at gmail dot com
2012-09-16 18:47 ` redi at gcc dot gnu.org
2012-09-17 14:18 ` pedzsan at gmail dot com
2012-10-01 16:31 ` paolo.carlini at oracle dot com
2012-10-03 17:53 ` dje at gcc dot gnu.org
2013-01-30 16:59 ` dje at gcc dot gnu.org
2013-01-30 21:58 ` dje at gcc dot gnu.org
2013-01-31  4:53 ` dje at gcc dot gnu.org
2013-01-31  5:50 ` pedzsan at gmail dot com
2013-01-31  6:11 ` dje at gcc dot gnu.org
2013-02-01 20:27 ` dje at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).