Using __cxa_atexit on Solaris

rvyas rishabh.a.vyas@gmail.com
Tue Nov 16 21:25:00 GMT 2010


Hi,

We recently had a weird memory corruption issue in our project during
destruction. The problem boiled down to order of destruction of
statics. They should have been destroyed in the exact reverse order of
the completion of their respective constructors. However gcc did not
preserve the order of destruction across block scope statics and
namespace scope statics.

According to this post (http://gcc.gnu.org/ml/gcc-bugs/2006-02/
msg01308.html), building gcc with  --enable-__cxa_atexit would solve
the issue. I built gcc 4.3.3 with this option but it still didn't seem
to solve the option. I also tried compiling the code with "-fuse-cxa-
atexit" option and got the following linking error.

/var/tmp//cc3nl8Dr.o: In function
`__static_initialization_and_destruction_0(int, int)':
temp.cpp:(.text+0x6a): undefined reference to `__cxa_atexit'
temp.cpp:(.text+0xaf): undefined reference to `__cxa_atexit'
temp.cpp:(.text+0xe0): undefined reference to `__cxa_atexit'
temp.cpp:(.text+0x13f): undefined reference to `__cxa_atexit'
temp.cpp:(.text+0x17c): undefined reference to `__cxa_atexit'
/var/tmp//cc3nl8Dr.o:temp.cpp:
(.text._ZN9singletonI6StaticILi1EEE8instanceEPKc[singleton<Static<1>
>::instance(char const*)]+0x6f): more undefined references to

`__cxa_atexit' follow
collect2: ld returned 1 exit status

My OS details are as follows - SunOS 5.10 Generic_127128-11 i86pc i386
i86pc

Any suggestions on how to make it work?

Thanks,
Rishabh 
-- 
View this message in context: http://old.nabble.com/Using-__cxa_atexit-on-Solaris-tp30232909p30232909.html
Sent from the gcc - Help mailing list archive at Nabble.com.



More information about the Gcc-help mailing list