Skip to content

Commit 73ab917

Browse files
noahricCommit bot
noahric
authored and
Commit bot
committed
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}
1 parent 39607c9 commit 73ab917

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

webrtc/base/flags.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,10 @@ int FlagList::SetFlagsFromCommandLine(int* argc, const char** argv,
257257

258258
void FlagList::Register(Flag* flag) {
259259
assert(flag != NULL && strlen(flag->name()) > 0);
260-
RTC_CHECK(!Lookup(flag->name())) << "flag " << flag->name()
261-
<< " declared twice";
260+
// NOTE: Don't call Lookup() within Register because it accesses the name_
261+
// of other flags in list_, and if the flags are coming from two different
262+
// compilation units, the initialization order between them is undefined, and
263+
// this will trigger an asan initialization-order-fiasco error.
262264
flag->next_ = list_;
263265
list_ = flag;
264266
}

0 commit comments

Comments
 (0)