[llvm-dev] initialization-order-fiasco in MCTargetDesc/X86MCAsmInfo.cpp

Kostya Serebryany via llvm-dev llvm-dev at lists.llvm.org
Fri Nov 11 13:44:54 PST 2016


Mehdi, Teresa,

Not sure if this is caused by one of your recent commits, or by someone
else's,
please excuse me if that's unrelated to your work...

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/542/steps/check-llvm%20asan/logs/stdio

==26383==ERROR: AddressSanitizer: initialization-order-fiasco on
address 0x000002ef41d8 at pc 0x0000009d1aa5 bp 0x7ffd0cd72b50 sp
0x7ffd0cd72b48
READ of size 4 at 0x000002ef41d8 thread T0
    #0 0x9d1aa4 in getValue
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/CommandLine.h:1229:38
    #1 0x9d1aa4 in operator AsmWriterFlavorTy
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/CommandLine.h:1233
    #2 0x9d1aa4 in llvm::X86ELFMCAsmInfo::X86ELFMCAsmInfo(llvm::Triple
const&) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp:100
    #3 0x9cf3e1 in createX86MCAsmInfo(llvm::MCRegisterInfo const&,
llvm::Triple const&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp:179:15
    #4 0x421020 in createMCAsmInfo
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/TargetRegistry.h:298:12
    #5 0x421020 in Context
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/unittests/MC/DwarfLineTables.cpp:41
    #6 0x421020 in __cxx_global_var_init
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/unittests/MC/DwarfLineTables.cpp:49
    #7 0x421020 in _GLOBAL__sub_I_DwarfLineTables.cpp
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/unittests/MC/DwarfLineTables.cpp
    #8 0x102efcc in __libc_csu_init
(/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_asan/unittests/MC/MCTests+0x102efcc)
    #9 0x7f57fa3d8ed4 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21ed4)
    #10 0x4b4222 in _start
(/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_asan/unittests/MC/MCTests+0x4b4222)

0x000002ef41d8 is located 152 bytes inside of global variable
'AsmWriterFlavor' defined in
'/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp:31:1'
(0x2ef4140) of size 600
  registered at:
    #0 0x4c63fd in __asan_register_globals.part.15
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_globals.cc:338
    #1 0x9d3f9b in asan.module_ctor
(/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_asan/unittests/MC/MCTests+0x9d3f9b)


The reports seems correct.
The flag object AsmWriterFlavor is used before it is initialized in
initialization of some other global object.

This makes the asan bot red... :(

Thanks,
--kcc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161111/6b1a2340/attachment.html>


More information about the llvm-dev mailing list