From 73ab917d27b6e66f075802c473cdec3d605ef5e5 Mon Sep 17 00:00:00 2001 From: noahric Date: Thu, 14 Jul 2016 18:21:11 -0700 Subject: [PATCH] Remove CHECK around duplicate FLAG lookup. It causes an asan initialization-order-fiasco in trying to read the names of other globally constructed data: ==21449==ERROR: AddressSanitizer: initialization-order-fiasco on address 0x7f6f297bc5e8 at pc 0x7f6f26b332a7 bp 0x7ffd479f8cb0 sp 0x7ffd479f8ca8 READ of size 8 at 0x7f6f297bc5e8 thread T0 #0 0x7f6f26b332a6 in name webrtc/base/flags.h:83:38 #1 0x7f6f26b332a6 in Lookup webrtc/base/flags.cc:133 #2 0x7f6f26b332a6 in rtc::FlagList::Register(rtc::Flag*) webrtc/base/flags.cc:260 #3 0x7f6f2529972b in __cxx_global_var_init.1 BUG= Review-Url: https://codereview.webrtc.org/2110963004 Cr-Commit-Position: refs/heads/master@{#13479} --- webrtc/base/flags.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webrtc/base/flags.cc b/webrtc/base/flags.cc index 0c0f4491c8..248c5c3f18 100644 --- a/webrtc/base/flags.cc +++ b/webrtc/base/flags.cc @@ -257,8 +257,10 @@ int FlagList::SetFlagsFromCommandLine(int* argc, const char** argv, void FlagList::Register(Flag* flag) { assert(flag != NULL && strlen(flag->name()) > 0); - RTC_CHECK(!Lookup(flag->name())) << "flag " << flag->name() - << " declared twice"; + // NOTE: Don't call Lookup() within Register because it accesses the name_ + // of other flags in list_, and if the flags are coming from two different + // compilation units, the initialization order between them is undefined, and + // this will trigger an asan initialization-order-fiasco error. flag->next_ = list_; list_ = flag; }