LLVM build failures of Sanitized builds

Hi.

Failure 1:
Current clang-6.0 from http://apt.llvm.org/, current sources.

$ CC=clang-6.0 CXX=clang++-6.0 cmake
-DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi;compiler-rt;lld;polly;openmp"
-DLLVM_USE_SANITIZER="Address;Undefined" -DCMAKE_BUILD_TYPE=Release
-GNinja ../llvm
$ ninja
[200/3921] Building Attributes.gen...
FAILED: include/llvm/IR/Attributes.gen.tmp
cd /build/build-test && /build/build-test/bin/llvm-tblgen -gen-attrs
-I /build/llvm/include/llvm/IR -I /build/llvm/include
/build/llvm/include/llvm/IR/Attributes.td -o
include/llvm/IR/Attributes.gen.tmp -d include/llvm/IR/Attributes.gen.d
==1216==AddressSanitizer CHECK failed:
/build/llvm-toolchain-snapshot-6.0~svn309928/projects/compiler-rt/lib/asan/asan_posix.cc:102
"((tsd_key_inited)) != (0)" (0x0, 0x0)
    <empty stack>

Aborted
[201/3921] Building Intrinsics.gen...
FAILED: include/llvm/IR/Intrinsics.gen.tmp
cd /build/build-test && /build/build-test/bin/llvm-tblgen
-gen-intrinsic -I /build/llvm/include/llvm/IR -I /build/llvm/include
/build/llvm/include/llvm/IR/Intrinsics.td -o
include/llvm/IR/Intrinsics.gen.tmp -d include/llvm/IR/Intrinsics.gen.d
==1217==AddressSanitizer CHECK failed:
/build/llvm-toolchain-snapshot-6.0~svn309928/projects/compiler-rt/lib/asan/asan_posix.cc:102
"((tsd_key_inited)) != (0)" (0x0, 0x0)
    <empty stack>

Aborted
[209/3921] Building CXX object lib/MC/CMakeFiles/LLVMMC.dir/MCStreamer.cpp.o
ninja: build stopped: subcommand failed.
$ clang-6.0 --version
clang version 6.0.0-svn309928-1~exp1 (trunk)
...

Failure 2, stage2 build is broken: (may have been fixed, did not re-check)
https://bugs.llvm.org/show_bug.cgi?id=33632

What am i doing wrong? Is there really no buildbots to catch these
sanitized build failures?

Roman.

Reported as https://bugs.llvm.org/show_bug.cgi?id=34085
I must be doing something really wrong...

Can you run the the program in the debugger and post a full backtrace of the crash?

Kuba

https://bugs.llvm.org/show_bug.cgi?id=34085#c3 suggests that it was regressed
by https://reviews.llvm.org/rL309914 ("[asan] Allocator support for Fuchsia"):

Can you run the the program in the debugger and post a full backtrace of the crash?

$ cat test.c
int main() {return 0;}
$ clang-6.0 /tmp/test.c -fsanitize=address -g -ggdb
$ gdb a.out
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/&gt;\.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/&gt;\.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
No symbol table is loaded. Use the "file" command.
Breakpoint 1 (__ubsan_handle_load_invalid_value) pending.
No symbol table is loaded. Use the "file" command.
Breakpoint 2 (__asan_report_error) pending.
Reading symbols from a.out...done.
(gdb) r
Starting program: /tmp/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
==4271==AddressSanitizer CHECK failed:
/build/llvm-toolchain-snapshot-6.0~svn310042/projects/compiler-rt/lib/asan/asan_posix.cc:102
"((tsd_key_inited)) != (0)" (0x0, 0x0)
    <empty stack>

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) thread apply all bt full

Thread 1 (Thread 0x7ffff7fbd780 (LWP 4271)):
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
        set = {__val = {0, 5212154, 0, 72057594037927936, 5363728,
4271, 0, 5509288, 140737488338896, 0, 0, 30, 18516376,
140737351941268, 1, 0}}
        pid = <optimized out>
        tid = <optimized out>
#1 0x00007ffff6f2c42a in __GI_abort () at abort.c:89
        save_stage = 2
        act = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction =
0x0}, sa_mask = {__val = {0, 140737488338736, 140737488338544, 0,
65365, 65365, 1, 0, 0, 0, 1, 10126144, 0, 2, 0, 0}}, sa_flags = 0,
          sa_restorer = 0x11a8998 <__sanitizer::CheckFailed(char
const*, int, char const*, unsigned long long, unsigned long
long)::num_calls>}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#2 0x000000000050016b in __sanitizer::Abort() ()
No symbol table info available.
#3 0x00000000004fe03b in __sanitizer::Die() ()
No symbol table info available.
#4 0x00000000004e20c9 in __asan::AsanCheckFailed(char const*, int,
char const*, unsigned long long, unsigned long long) ()
No symbol table info available.
#5 0x00000000004fe096 in __sanitizer::CheckFailed(char const*, int,
char const*, unsigned long long, unsigned long long) ()
No symbol table info available.
#6 0x00000000004dd5a9 in __asan::AsanTSDGet() ()
No symbol table info available.
#7 0x00000000004e6c99 in __asan::GetCurrentTidOrInvalid() ()
No symbol table info available.
#8 0x00000000004ddc07 in
__asan::ScopedInErrorReport::ScopedInErrorReport(bool) ()
No symbol table info available.
#9 0x00000000004df6eb in __asan::ReportFreeNotMalloced(unsigned long,
__sanitizer::BufferedStackTrace*) ()
No symbol table info available.
#10 0x00000000004243eb in __asan::asan_free(void*,
__sanitizer::BufferedStackTrace*, __asan::AllocType) ()
No symbol table info available.
#11 0x00000000004d875d in cfree ()
No symbol table info available.
#12 0x00007ffff74ad5d5 in _dlerror_run
(operate=operate@entry=0x7ffff74ad000 <dlsym_doit>,
args=args@entry=0x7fffffffdd70) at dlerror.c:159
        result = 0x754480 <alloc_memory_for_dlsym>
#13 0x00007ffff74ad068 in __dlsym (handle=<optimized out>,
name=<optimized out>) at dlsym.c:70
        args = {handle = 0xffffffffffffffff, name = 0x51022c
"__isoc99_sprintf", who = 0x4e73bc
<__interception::GetRealFunctionAddress(char const*, unsigned long*,
unsigned long, unsigned long)+28>, sym = 0x7ffff6f3ed30
<_IO_vfprintf_internal>}
        result = <optimized out>
#14 0x00000000004e73bc in __interception::GetRealFunctionAddress(char
const*, unsigned long*, unsigned long, unsigned long) ()
No symbol table info available.
#15 0x00000000004c25cd in __asan::InitializeAsanInterceptors() ()
No symbol table info available.
#16 0x00000000004e3f68 in __asan::AsanInitInternal() [clone .part.0] ()
No symbol table info available.
#17 0x00007ffff7de8a02 in _dl_init (main_map=0x7ffff7ffe170, argc=1,
argv=0x7fffffffde78, env=0x7fffffffde88) at dl-init.c:105
        addrs = <optimized out>
        cnt = <optimized out>
        preinit_array = <optimized out>
        preinit_array_size = <optimized out>
        i = <optimized out>
#18 0x00007ffff7dd9c5a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
        tls_init_tp_called = true
        version_info = 0
        relocate_time = 538393
        load_time = 767681
        audit_list = 0x0
        _dl_rtld_libname2 = {name = 0x0, next = 0x0, dont_free = 0}
        library_path = 0x0
        start_time = 1821373415862
        preloadlist = 0x0
        any_debug = 0
        _dl_rtld_libname = {name = 0x400270
"/lib64/ld-linux-x86-64.so.2", next = 0x7ffff7ffdfd0 <newname>,
dont_free = 0}
        _dl_skip_args = 0
        audit_list_string = 0x0
        _rtld_global = {_dl_ns = {{_ns_loaded = 0x7ffff7ffe170,
_ns_nloaded = 9, _ns_main_searchlist = 0x7ffff7ffe428,
_ns_global_scope_alloc = 0, _ns_unique_sym_table = {lock = {mutex =
{__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind
= 1,
---Type <return> to continue, or q <return> to quit---
                      __spins = 0, __elision = 0, __list = {__prev =
0x0, __next = 0x0}}, __size = '\000' <repeats 16 times>, "\001",
'\000' <repeats 22 times>, __align = 0}}, entries = 0x0, size = 0,
n_elements = 0, free = 0x0}, _ns_debug = {r_version = 0,
                r_map = 0x0, r_brk = 0, r_state = RT_CONSISTENT,
r_ldbase = 0}}, {_ns_loaded = 0x0, _ns_nloaded = 0,
_ns_main_searchlist = 0x0, _ns_global_scope_alloc = 0,
_ns_unique_sym_table = {lock = {mutex = {__data = {__lock = 0, __count
= 0, __owner = 0,
                      __nusers = 0, __kind = 0, __spins = 0, __elision
= 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats
39 times>, __align = 0}}, entries = 0x0, size = 0, n_elements = 0,
free = 0x0}, _ns_debug = {r_version = 0, r_map = 0x0,
                r_brk = 0, r_state = RT_CONSISTENT, r_ldbase = 0}}
<repeats 15 times>}, _dl_nns = 1, _dl_load_lock = {mutex = {__data =
{__lock = 1, __count = 1, __owner = 4271, __nusers = 1, __kind = 1,
__spins = 0, __elision = 0, __list = {__prev = 0x0,
                  __next = 0x0}}, __size =
"\001\000\000\000\001\000\000\000\257\020\000\000\001\000\000\000\001",
'\000' <repeats 22 times>, __align = 4294967297}}, _dl_load_write_lock
= {mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers =
0,
                __kind = 1, __spins = 0, __elision = 0, __list =
{__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 16 times>,
"\001", '\000' <repeats 22 times>, __align = 0}}, _dl_load_adds = 9,
_dl_initfirst = 0x0, _dl_cpuclock_offset = 1821373450724,
          _dl_profile_map = 0x0, _dl_num_relocations = 229,
_dl_num_cache_relocations = 3, _dl_all_dirs = 0x7ffff7ff5000,
_dl_error_catch_tsd = 0x7ffff7017810 <__libc_dl_error_tsd>,
_dl_rtld_map = {l_addr = 140737351880704,
            l_name = 0x400270 "/lib64/ld-linux-x86-64.so.2", l_ld =
0x7ffff7ffce70, l_next = 0x0, l_prev = 0x7ffff7fc0000, l_real =
0x7ffff7ffd9d8 <_rtld_global+2456>, l_ns = 0, l_libname =
0x7ffff7ffe020 <_dl_rtld_libname>, l_info = {0x0, 0x0, 0x7ffff7ffcef0,
              0x7ffff7ffcee0, 0x7ffff7ffce80, 0x7ffff7ffcea0,
0x7ffff7ffceb0, 0x7ffff7ffcf20, 0x7ffff7ffcf30, 0x7ffff7ffcf40,
0x7ffff7ffcec0, 0x7ffff7ffced0, 0x0, 0x0, 0x7ffff7ffce70, 0x0, 0x0,
0x0, 0x0, 0x0, 0x7ffff7ffcf00, 0x0, 0x0, 0x7ffff7ffcf10,
              0x0 <repeats 12 times>, 0x7ffff7ffcf60, 0x7ffff7ffcf50,
0x0, 0x0, 0x7ffff7ffcf80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x7ffff7ffcf70, 0x0 <repeats 25 times>, 0x7ffff7ffce90}, l_phdr =
0x7ffff7dd9040, l_entry = 0, l_phnum = 7, l_ldnum = 0,
            l_searchlist = {r_list = 0x0, r_nlist = 0},
l_symbolic_searchlist = {r_list = 0x0, r_nlist = 0}, l_loader = 0x0,
l_versions = 0x7ffff7fc1098, l_nversions = 6, l_nbuckets = 17,
l_gnu_bitmask_idxbits = 3, l_gnu_shift = 8, l_gnu_bitmask =
0x7ffff7dd92c0, {
              l_gnu_buckets = 0x7ffff7dd92e0, l_chain =
0x7ffff7dd92e0}, {l_gnu_chain_zero = 0x7ffff7dd9320, l_buckets =
0x7ffff7dd9320}, l_direct_opencount = 0, l_type = lt_library,
l_relocated = 1, l_init_called = 0, l_global = 1, l_reserved = 0,
            l_phdr_allocated = 0, l_soname_added = 0, l_faked = 0,
l_need_tls_init = 0, l_auditing = 0, l_audit_any_plt = 0, l_removed =
0, l_contiguous = 0, l_symbolic_in_local_scope = 0, l_free_initfini =
0, l_rpath_dirs = {dirs = 0x0, malloced = 0},
            l_reloc_result = 0x0, l_versyms = 0x7ffff7dd97d8, l_origin
= 0x0, l_map_start = 140737351880704, l_map_end = 140737354129776,
l_text_end = 140737351996320, l_scope_mem = {0x0, 0x0, 0x0, 0x0},
l_scope_max = 0, l_scope = 0x0, l_local_scope = {0x0, 0x0},
            l_file_id = {dev = 0, ino = 0}, l_runpath_dirs = {dirs =
0x0, malloced = 0}, l_initfini = 0x0, l_reldeps = 0x0, l_reldepsmax =
0, l_used = 1, l_feature_1 = 0, l_flags_1 = 0, l_flags = 0, l_idx = 0,
l_mach = {plt = 0, gotplt = 0, tlsdesc_table = 0x0},
            l_lookup_cache = {sym = 0x7ffff7dd9438, type_class = 1,
value = 0x7ffff7ffe170, ret = 0x4030b8}, l_tls_initimage = 0x0,
l_tls_initimage_size = 0, l_tls_blocksize = 0, l_tls_align = 0,
l_tls_firstbyte_offset = 0, l_tls_offset = 0, l_tls_modid = 0,
            l_tls_dtor_count = 0, l_relro_addr = 2243520, l_relro_size
= 1088, l_serial = 0, l_audit = 0x7ffff7ffde48 <_rtld_global+3592>},
audit_data = {{cookie = 0, bindflags = 0} <repeats 16 times>},
          _dl_rtld_lock_recursive = 0x7ffff7bc5b20
<__GI___pthread_mutex_lock>, _dl_rtld_unlock_recursive =
0x7ffff7bc7290 <__GI___pthread_mutex_unlock>,
_dl_make_stack_executable_hook = 0x7ffff7bc2890
<__make_stacks_executable>, _dl_stack_flags = 6,
          _dl_tls_dtv_gaps = false, _dl_tls_max_dtv_idx = 2,
_dl_tls_dtv_slotinfo_list = 0x7ffff7fc1128, _dl_tls_static_nelem = 2,
_dl_tls_static_size = 4224, _dl_tls_static_used = 208,
_dl_tls_static_align = 64, _dl_initial_dtv = 0x7ffff7fbe090,
          _dl_tls_generation = 1, _dl_init_static_tls = 0x7ffff7bc2f90
<__pthread_init_static_tls>, _dl_wait_lookup_done = 0x7ffff7bc30b0
<__wait_lookup_done>, _dl_scope_free_list = 0x0}
        __GI__dl_argv = 0x7fffffffde78
        __pointer_chk_guard_local = 16186278836837982313
        _rtld_global_ro = {_dl_debug_mask = 0, _dl_osversion = 264971,
_dl_platform = 0x7fffffffe209 "x86_64", _dl_platformlen = 6,
_dl_pagesize = 4096, _dl_inhibit_cache = 0, _dl_initial_searchlist =
{r_list = 0x7ffff7fc0638, r_nlist = 8}, _dl_clktck = 100,
          _dl_verbose = 0, _dl_debug_fd = 2, _dl_lazy = 1,
_dl_bind_not = 0, _dl_dynamic_weak = 0, _dl_fpu_control = 895,
_dl_correct_cache_id = 771, _dl_hwcap = 395049983, _dl_hwcap_mask = 0,
_dl_auxv = 0x7fffffffe0b8, _dl_x86_cpu_features = {kind =
arch_kind_amd,
            max_cpuid = 13, cpuid = {{eax = 6295328, ebx = 117966848,
ecx = 1050161675, edx = 395049983}, {eax = 0, ebx = 8, ecx = 0, edx =
0}, {eax = 6295328, ebx = 268435456, ecx = 32227327, edx =
802421759}}, family = 21, model = 2, feature = {49600}},
          _dl_inhibit_rpath = 0x0, _dl_origin_path = 0x0,
_dl_use_load_bias = 18446744073709551615, _dl_profile = 0x0,
_dl_profile_output = 0x7ffff7df541c "/var/tmp", _dl_trace_prelink =
0x0, _dl_trace_prelink_map = 0x0, _dl_init_all_dirs = 0x7ffff7ff5000,
          _dl_sysinfo_dso = 0x7ffff7ffa000, _dl_sysinfo_map =
0x7ffff7ffe708, _dl_hwcap2 = 0, _dl_debug_printf = 0x7ffff7de9730
<_dl_debug_printf>, _dl_catch_error = 0x7ffff7de86d0
<_dl_catch_error>, _dl_signal_error = 0x7ffff7de8490
<_dl_signal_error>,
          _dl_mcount = 0x7ffff7deab30 <__GI__dl_mcount>,
_dl_lookup_symbol_x = 0x7ffff7de2f60 <_dl_lookup_symbol_x>,
_dl_check_caller = 0x7ffff7dec0c0 <_dl_check_caller>, _dl_open =
0x7ffff7dec640 <_dl_open>, _dl_close = 0x7ffff7dee660 <_dl_close>,
          _dl_tls_get_addr_soft = 0x7ffff7debc40
<_dl_tls_get_addr_soft>, _dl_discover_osversion = 0x7ffff7df0f70
<_dl_discover_osversion>, _dl_audit = 0x0, _dl_naudit = 0}
        _dl_argc = 1
#19 0x0000000000000001 in ?? ()
No symbol table info available.
#20 0x00007fffffffe217 in ?? ()
No symbol table info available.
#21 0x0000000000000000 in ?? ()
No symbol table info available.
(gdb) q
A debugging session is active.

        Inferior 1 [process 4271] will be killed.

Quit anyway? (y or n) y

Kuba

Roman.