問題タブ [address-sanitizer]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - Two problems with Address Sanitizer
In a hobby project I use the address sanitizer (-fsanitize=address) and g++-6 (Homebrew GCC 6.3.0_1) 6.3.0.
I got an error that I do not understand, which is:
==94266==AddressSanitizer CHECK failed: ../../../../libsanitizer/asan/asan_globals.cc:146 "((AddrIsAlignedByGranularity(g->size_with_redzone))) != (0)" (0x0, 0x0)
#0 0x10b60cd3d in __asan::AsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (libasan.3.dylib+0x5dd3d)
#1 0x10b612be3 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (libasan.3.dylib+0x63be3)
After playing around for a while, I noticed that I am using regex in two different classes, and if I remove either one of them, the problem disappears. I want to understand why and what I can do about that.
So, my next attempt is to build a minimum example of the problem, and I came up with the following:
If I compile with "g++-6 -fsanitize=address a.cpp m.cpp" and then run "./a.out", the program hangs forever, while "g++-6 a.cpp m.cpp" followed by "./a.out" just works as expected.
This is not the exactly what I wanted to demonstrate here (as I do not get the AddressSanitizer CHECK failed error), but the problems could be related?
I do see a few of these as well, just to be complete:
ld: warning: direct access in function '__GLOBAL__sub_D_00099_0_a.cpp' from file '/var/folders/lq/t18hc5bn0c5bxf7h7nn609f40000gp/T//ccTC4rgj.o' to global weak symbol 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > std::__cxx11::regex_traits<char>::lookup_collatename<char const*>(char const*, char const*) const::__collatenames' from file '/var/folders/lq/t18hc5bn0c5bxf7h7nn609f40000gp/T//ccTC4rgj.o' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
edit: forgot to mention one detail I also noticed. If I comment out the regex var 're' in m.cpp, the problem also disappears completely.
Thanks for any help!