[Bug sanitizer/56393] SIGSEGV when -fsanitize=address and dynamic lib with global objects

eugeni.stepanov at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Feb 19 20:38:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56393

Evgeniy Stepanov <eugeni.stepanov at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eugeni.stepanov at gmail
                   |                            |dot com

--- Comment #7 from Evgeniy Stepanov <eugeni.stepanov at gmail dot com> 2013-02-19 20:35:12 UTC ---
You've got a constructor of an uninstrumented shared library calling back into
the application code. Of course, it happens before constructors of the main
executable run. This breaks ASan initialization order.

boost::get_static_exception_object<boost::bad_alloc_> is compiled in both
hoge1.o and hoge2.o, both as weak symbols, one of them is ASan-instrumented.
The call from a shared library constructor is resolved to the instrumented
version from the main executable.

This shows that bad things can happen implicitly, in very harmlessly looking
code. We probably should not rely on normal constructors and switch
.preinit_array. The only thing that is stronger than .preinit_array is
DF_1_INITFIRST, we can't use it with static libasan, unfortunately.



More information about the Gcc-bugs mailing list