Hello. First of all, thank you for reading my post, and thank in advance for your responses. I am experiencing some troubles with static initialization in a program compiled with gcc3.4.3 under solaris10 for intel. I use to compile it under 8 different configurations: debug_32bits_dynamic, debug_32bits_static, release_32bits_dynamic, release_32bits_static, debug_64bits_dynamic, debug_64bits_static, release_64bits_dynamic, release_64bits_static, varying the compilation flags. The problems shows up Only in Solaris10, gcc3.4.3, debug_32bits_dynamic ( -m32 -gdwarf -DDEBUG -D_DEBUG -shared-libgcc ). The problem ----------- In short I have a class "Logger". In its constructor are initialized some static pointers. 1) first a static Logger object start constructing. 2) In the midle of the constructor, another static Logger object from another translation unit start its constructor 3) It enters for second time in the initialization of the same static pointers before the first initialization finished. My question is. Where can I search for information about static initialization in order to avoid this? How can I modify my code? I apologizes for not submitting a short example. It is very difficult to me to reproduce this behaivour with a short program. I used the same library -the one that contains Logger class- in several executables, only in one of them with certain compilation flags it shows up. Anyway I send a commented backtrace of my production program. Hint: read the comments in order. ----------------------------------------------------------------------------------------------------------------- 5) To complete my tragedy, the initialization is thread safe, so I get a deadlock: this is a spin-lock. ----------------------------------------------------------------------------------------------------------------- #0 0xfe94cdd0 in ats::base::AtomicGet () from /export/home/ATS-AR/jfranzoy/lib/libAtsBase_1-20D.so ----------------------------------------------------------------------------------------------------------------- 4) and my initialization gets called for second time before the first initialization is finished. ----------------------------------------------------------------------------------------------------------------- #1 0xfe9a1d1f in ats::base::log::logger_impl::root () at ../../src/ats/base/log/Logger.cpp:363 #2 0xfeb0633c in ats::base::log::logger_impl::lookup (name=@0x8046f00) at ../../src/ats/base/log/Logger.cpp:300 ----------------------------------------------------------------------------------------------------------------- 3) In this fame (#3) start the construction of another Logger ----------------------------------------------------------------------------------------------------------------- #3 0xfe9a1f67 in Logger (this=0xfee64b0c, name=@0x8046f00) at ../../src/ats/base/log/Logger.cpp:371 #4 0xfedfb894 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at ../../Src/msg/RtdbMsg.cpp:38 #5 0xfedfb975 in global constructors keyed to _ZN3ats4base9date_time54_GLOBAL__N_.._.._Src_msg_RtdbMsg.cpp_9D2164D3_A69317B715equalIgnoreCaseEPKcS4_ () at ../../Src/msg/RtdbMsg.cpp:56 #6 0xfedfdc0d in __do_global_ctors_aux () at /usr/sfw/lib/gcc/i386-pc-solaris2.10/3.4.3/../../../../include/c++/3.4.3/iostream:77 #7 0xfedfdc3a in _init () at /usr/sfw/lib/gcc/i386-pc-solaris2.10/3.4.3/../../../../include/c++/3.4.3/iostream:77 #8 0xfefd4bd5 in call_init () from /lib/ld.so.1 #9 0xfefd4989 in is_dep_init () from /lib/ld.so.1 #10 0xfefdef8a in elf_bndr () from /lib/ld.so.1 #11 0xfefcab04 in elf_rtbndr () from /lib/ld.so.1 #12 0xfeff0e80 in ?? () #13 0x00000618 in ?? () #14 0xfe97266e in ats::base::getEnvironmentVariable (variableName=0x80cc224 "LOG_LEVEL", buffer=0x8047098 "´p\004\bØ\201ýþ\001", size=128) at ../../src/ats/base/Platform.cpp:110 #15 0xfeb06166 in ats::base::log::logger_impl::defaultPriority (name=@0x8102354) at ../../src/ats/base/log/Logger.cpp:266 #16 0xfeb05f70 in logger_impl (this=0x8102350, name=@0x8047208, parent=0x0, appender={px = 0x80cc1c8, pn = {pi_ = 0x80cc1f0}}) at ../../src/ats/base/log/Logger.cpp:286 ----------------------------------------------------------------------------------------------------------------- 2) In logger_impl::root is my initialization of some static member pointers. ----------------------------------------------------------------------------------------------------------------- #17 0xfe9a1bb7 in ats::base::log::logger_impl::root () at ../../src/ats/base/log/Logger.cpp:361 #18 0xfeb0633c in ats::base::log::logger_impl::lookup (name=@0x8047378) at ../../src/ats/base/log/Logger.cpp:300 ----------------------------------------------------------------------------------------------------------------- 1) In this fame (#19) start the construction of the first logger object. lookup and root are logger_impl static members. In root() a logger_impl object is created, in logger_impl ctor defaultPriority and then getEnvironmentVariable gets called. The last one is in another translation unit, aparently a nested static initialization starts there. ----------------------------------------------------------------------------------------------------------------- #19 0xfe9a1f67 in Logger (this=0xfefac100, name=@0x8047378) at ../../src/ats/base/log/Logger.cpp:371 #20 0xfeeb85d6 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at ../../src/cpp/AtsStore.cpp:27 #21 0xfeeb86b7 in global constructors keyed to _ZN3ats4base9date_time55_GLOBAL__N_.._.._src_cpp_AtsStore.cpp_9D2164D3_EC01552B15equalIgnoreCaseEPKcS4_ () at ../../src/cpp/AtsStore.cpp:1449 #22 0xfeef26f5 in __do_global_ctors_aux () at ../../../AtsBase/Export/ats/base/date_time/DateTime.hpp:2769 #23 0xfeef271a in _init () at ../../../AtsBase/Export/ats/base/date_time/DateTime.hpp:2769 #24 0xfefd4bd5 in call_init () from /lib/ld.so.1 #25 0xfefd4989 in is_dep_init () from /lib/ld.so.1 #26 0xfefdef8a in elf_bndr () from /lib/ld.so.1 #27 0xfefcab04 in elf_rtbndr () from /lib/ld.so.1 #28 0xfeff0e80 in ?? () #29 0x00006ed0 in ?? () #30 0xfeb17afc in ats::base::alloc::shared_ptr<sockaddr>::swap (this=0x80474ec, other=@0xfecafc10) at ../../Export/ats/base/alloc/shared_ptr.hpp:256 #31 0xfeb171aa in ats::base::alloc::shared_ptr<sockaddr>::reset<sockaddr, void (*)(sockaddr*)> (this=0xfecafc10, p=0x80de5b8, d=0xfe9afc18 <delete_sockaddr>) at ../../Export/ats/base/alloc/shared_ptr.hpp:208 #32 0xfe9b00c9 in ats::base::io::SocketAddress::init (this=0xfecafc08, sockaddr_=0x80de450, addr_len_=16) at ../../src/ats/base/io/SocketAddress.cpp:211 #33 0xfe9b038d in ats::base::io::SocketAddress::init (this=0xfecafc08, name=0xfeb9fcf2 "0.0.0.0:0", resolve=false, protocol=ats::base::io::SocketAddress::SOCKET_ADDRESS_PROTO_UNSPECIFIED) at ../../src/ats/base/io/SocketAddress.cpp:262 #34 0xfeb82fd4 in SocketAddress (this=0xfecafc08, name=0xfeb9fcf2 "0.0.0.0:0", resolve=false, protocol=ats::base::io::SocketAddress::SOCKET_ADDRESS_PROTO_UNSPECIFIED) at ../../Export/ats/base/io/SocketAddress.hpp:117 #35 0xfea2bf9b in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at ../../src/ats/base/sctp/SctpEndPointAddress.cpp:617 #36 0xfea2bfd9 in global constructors keyed to _ZN3ats4base9date_time76_GLOBAL__N_.._.._src_ats_base_sctp_SctpEndPointAddress.cpp_9D2164D3_51112AC515equalIgnoreCaseEPKcS4_ () at ../../src/ats/base/sctp/SctpEndPointAddress.cpp:696 #37 0xfea49901 in __do_global_ctors_aux () at /usr/include/sys/stat_impl.h:165 #38 0xfea4992a in _init () at /usr/include/sys/stat_impl.h:165 #39 0xfefd4bd5 in call_init () from /lib/ld.so.1 #40 0xfefd412c in setup () from /lib/ld.so.1 #41 0xfefdffce in _setup () from /lib/ld.so.1 #42 0xfefca9ec in _rt_boot () from /lib/ld.so.1 #43 0x08047928 in ?? () #44 0xfeffbaec in _GLOBAL_OFFSET_TABLE_ () from /lib/ld.so.1 #45 0x00000003 in ?? () #46 0x0804796c in ?? () #47 0x00000004 in ?? () #48 0x08047978 in ?? () #49 0x00000005 in ?? () #50 0x080479e0 in ?? () #51 0x00000000 in ?? () -- Juan Carlos Franzoy Licenciado en Sistemas