Re: c++ static initialization question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Juan Carlos Franzoy <jfranzoy@xxxxxxxxx> writes:

> I do not think it is a bug on gcc. I just want to know if there are
> some docs that describes how static initializations is in gcc.

As far as I know it is not documented.  I wrote some very shorts notes
at http://www.airs.com/blog/archives/51 .

The basic idea is pretty simple.  For static variables not defined in
any function, all the constructors are run at program startup time.
The order in which they are run is unspecified, except that within a
single file they are run in the order in which they appear in the
file.

The backtrace in http://gcc.gnu.org/ml/gcc-help/2010-03/msg00090.html
does not make much sense to me.  Somehow calling
ats::base::getEnvironmentVariable leads to a call to _init.  How does
that happen?  Do you have different shared libraries involved?  It
seems that perhaps a symbol in one shared library is referring to a
symbol defined in a different shared library, and that the Solaris
dynamic linker is deciding to run the static initializers in the
latter library.  This is then leading to the reentrant call.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux