http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56393
Bug #: 56393 Summary: SIGSEGV when -fsanitize=address and dynamic lib with global objects Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer AssignedTo: unassig...@gcc.gnu.org ReportedBy: t-gcc-bugzi...@snowelm.com CC: do...@gcc.gnu.org, dvyu...@gcc.gnu.org, ja...@gcc.gnu.org, k...@gcc.gnu.org Created attachment 29493 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29493 gdb session log When linked with a dynamic library with a globally initialized class object, a compiled code with address sanitizer dies with SIGSEGV. I think this is a typical usecase... Test case: (boost 1.53 was installed with --build-type=complete. tested by libs compiled with g++ 4.7.2 as well as libs compiled with head gcc) --------------------------------- #include <boost/thread/shared_mutex.hpp> #include <cstdio> int main() { printf("hello\n"); boost::upgrade_mutex m; } ---------------------------------- $ g++ -g -fsanitize=address -I/usr/local/include hoge2.cpp -o a.out -lboost_thread -lboost_system $ ./a.out Segmentation fault (core dumped) The segfault is before the printf. Without -fsanitize=address it runs normally. If the program is linked with static libs (-lboost_thread-mt-s -lboost_system-mt-s), it runs normally. Note that the libraries are compiled without -fsanitize=address. I investigated the situation by gdb (with -lboost_thread-mt-d -lboost_system-mt-d). Please see the attached log. For me it seems that some initializer in the shared lib kicks sanitized code of some object constructor before the sanitizer gets ready.