llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.42k stars 12.15k forks source link

[msan][aarch64][llvm-libunwind] Unwinder fails on ARM Msan builds #73837

Open vitalybuka opened 1 year ago

vitalybuka commented 1 year ago

Extracted from discussion in https://github.com/llvm/llvm-project/pull/72543

Full reproducer requires build setup like https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild with zorg/buildbot/builders/sanitizers/buildbot_bootstrap_msan.sh

ninja -C /b/my/build/libcxx_build_msan/ check-cxx will fail format tests

if we rerun some of them: MSAN_OPTIONS=fast_unwind_on_fatal=1:handle_abort=1:external_symbolizer_path=llvm_build0/bin/llvm-symbolizer

The stacks below looks like exception handler can not be found. This happens only on aarch64 Msan on Linux

/b/my/build/libcxx_build_msan/test/std/utilities/format/format.functions/Output/vformat.locale.pass.cpp.dir/t.tmp.exe
libc++abi: terminating due to uncaught exception of type std::__1::format_error: The argument index value is too large for the number of arguments supplied
MemorySanitizer:DEADLYSIGNAL
==1128068==ERROR: MemorySanitizer: ABRT on unknown address 0x03e700113684 (pc 0xffffbedf03f0 bp 0xffffce972130 sp 0xffffce972130 T1128068)
    #0 0xffffbedf03f0 in __pthread_kill_implementation nptl/pthread_kill.c:44:76
    #1 0xffffbedaa1e8 in raise signal/../sysdeps/posix/raise.c:26:13
    #2 0xffffbed96af8 in abort stdlib/abort.c:79:7
    #3 0xffffbf0bdd54 in abort_message abort_message.cpp
    #4 0xffffbf06f588 in demangling_terminate_handler() cxa_default_handlers.cpp
    #5 0xffffbf0bc558 in std::__terminate(void (*)()) cxa_handlers.cpp
    #6 0xffffbf0c37e0 in __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) cxa_exception.cpp
    #7 0xffffbf0c370c in __cxa_throw (/b/my/build/libcxx_build_msan/lib/libc++abi.so.1+0x8370c)
    #8 0xaaaacf59e1d8 in std::__1::__throw_format_error[abi:ne180000](char const*) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_error.h:43:3
    #9 0xaaaacf5a1148 in auto char const* std::__1::__format::__handle_replacement_field[abi:ne180000]<char const*, std::__1::basic_format_parse_context<char>, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(char const*, char const*, std::__1::basic_format_parse_context<char>&, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>&)::'lambda'(char const*)::operator()<std::__1::monostate>(char const*) const /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_functions.h:277:13
    #10 0xaaaacf5a10d8 in decltype(std::declval<char const*>()(std::declval<std::__1::monostate&>())) std::__1::__invoke[abi:ne180000]<char const* std::__1::__format::__handle_replacement_field[abi:ne180000]<char const*, std::__1::basic_format_parse_context<char>, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(char const*, char const*, std::__1::basic_format_parse_context<char>&, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>&)::'lambda'(char const*), std::__1::monostate&>(char const*&&, std::__1::monostate&) /b/my/build/libcxx_build_msan/include/c++/v1/__type_traits/invoke.h:344:25
    #11 0xaaaacf5a0528 in std::__1::invoke_result<char const*, std::__1::monostate&>::type std::__1::invoke[abi:ne180000]<char const* std::__1::__format::__handle_replacement_field[abi:ne180000]<char const*, std::__1::basic_format_parse_context<char>, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(char const*, char const*, std::__1::basic_format_parse_context<char>&, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>&)::'lambda'(char const*), std::__1::monostate&>(char const*&&, std::__1::monostate&) /b/my/build/libcxx_build_msan/include/c++/v1/__functional/invoke.h:30:12
    #12 0xaaaacf59f1d0 in decltype(auto) std::__1::__visit_format_arg[abi:ne180000]<char const* std::__1::__format::__handle_replacement_field[abi:ne180000]<char const*, std::__1::basic_format_parse_context<char>, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(char const*, char const*, std::__1::basic_format_parse_context<char>&, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>&)::'lambda'(char const*), std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(char const*&&, std::__1::basic_format_arg<std::__1::basic_format_parse_context<char>>) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_arg.h:103:12
    #13 0xaaaacf59e6a0 in char const* std::__1::__format::__handle_replacement_field[abi:ne180000]<char const*, std::__1::basic_format_parse_context<char>, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(char const*, char const*, std::__1::basic_format_parse_context<char>&, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>&) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_functions.h:274:5
    #14 0xaaaacf597f78 in std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>::iterator std::__1::__format::__vformat_to[abi:ne180000]<std::__1::basic_format_parse_context<char>, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(std::__1::basic_format_parse_context<char>&&, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>&&) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_functions.h:315:13
    #15 0xaaaacf5978d4 in T std::__1::__vformat_to[abi:ne180000]<std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, char, std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>>(T, std::__1::locale, std::__1::basic_string_view<T0, std::__1::char_traits<T0>>, std::__1::basic_format_args<std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, T0>>) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_functions.h:552:5
    #16 0xaaaacee00624 in std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>> std::__1::vformat_to[abi:ne180000]<std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>(std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::locale, std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_format_args<std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_functions.h:562:10
    #17 0xaaaacee00624 in std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> std::__1::vformat[abi:ne180000]<void>(std::__1::locale, std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_format_args<std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_functions.h:597:3
    #18 0xaaaacee00624 in auto $_1::operator()<char>(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string_view<char, std::__1::char_traits<char>>) const /b/my/build/llvm-project/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp:42:7
    #19 0xaaaacedea6b0 in void format_tests<char, (execution_modus)1, $_0, $_1>($_0, $_1) /b/my/build/llvm-project/libcxx/test/std/utilities/format/format.functions/format_tests.h:3148:3
    #20 0xaaaacede80d0 in main /b/my/build/llvm-project/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp:54:3
    #21 0xffffbed96dbc in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #22 0xffffbed96e94 in __libc_start_main csu/../csu/libc-start.c:360:3
    #23 0xaaaaced5a02c in _start (/b/my/build/libcxx_build_msan/test/std/utilities/format/format.functions/Output/vformat.locale.pass.cpp.dir/t.tmp.exe+0x10a02c)

MemorySanitizer can not provide additional info.
SUMMARY: MemorySanitizer: ABRT nptl/pthread_kill.c:44:76 in __pthread_kill_implementation
==1128068==ABORTING
vitalybuka commented 1 year ago

Note, at this moment these tests disabled on bots here https://github.com/llvm/llvm-zorg/blob/8842c8c262cce13e48cd8e382fc42693f142512d/zorg/buildbot/builders/sanitizers/buildbot_functions.sh#L357C8-L372C78

llvmbot commented 1 year ago

@llvm/issue-subscribers-backend-aarch64

Author: Vitaly Buka (vitalybuka)

Extracted from discussion in https://github.com/llvm/llvm-project/pull/72543 Full reproducer requires build setup like https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild with zorg/buildbot/builders/sanitizers/buildbot_bootstrap_msan.sh ninja -C /b/my/build/libcxx_build_msan/ check-cxx will fail format tests if we rerun some of them: `MSAN_OPTIONS=fast_unwind_on_fatal=1:handle_abort=1:external_symbolizer_path=llvm_build0/bin/llvm-symbolizer` The stacks below looks like exception handler can not be found. This happens only on aarch64 Msan on Linux ``` /b/my/build/libcxx_build_msan/test/std/utilities/format/format.functions/Output/vformat.locale.pass.cpp.dir/t.tmp.exe libc++abi: terminating due to uncaught exception of type std::__1::format_error: The argument index value is too large for the number of arguments supplied MemorySanitizer:DEADLYSIGNAL ==1128068==ERROR: MemorySanitizer: ABRT on unknown address 0x03e700113684 (pc 0xffffbedf03f0 bp 0xffffce972130 sp 0xffffce972130 T1128068) #0 0xffffbedf03f0 in __pthread_kill_implementation nptl/pthread_kill.c:44:76 #1 0xffffbedaa1e8 in raise signal/../sysdeps/posix/raise.c:26:13 #2 0xffffbed96af8 in abort stdlib/abort.c:79:7 #3 0xffffbf0bdd54 in abort_message abort_message.cpp #4 0xffffbf06f588 in demangling_terminate_handler() cxa_default_handlers.cpp #5 0xffffbf0bc558 in std::__terminate(void (*)()) cxa_handlers.cpp #6 0xffffbf0c37e0 in __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) cxa_exception.cpp #7 0xffffbf0c370c in __cxa_throw (/b/my/build/libcxx_build_msan/lib/libc++abi.so.1+0x8370c) #8 0xaaaacf59e1d8 in std::__1::__throw_format_error[abi:ne180000](char const*) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_error.h:43:3 #9 0xaaaacf5a1148 in auto char const* std::__1::__format::__handle_replacement_field[abi:ne180000]<char const*, std::__1::basic_format_parse_context<char>, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(char const*, char const*, std::__1::basic_format_parse_context<char>&, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>&)::'lambda'(char const*)::operator()<std::__1::monostate>(char const*) const /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_functions.h:277:13 #10 0xaaaacf5a10d8 in decltype(std::declval<char const*>()(std::declval<std::__1::monostate&>())) std::__1::__invoke[abi:ne180000]<char const* std::__1::__format::__handle_replacement_field[abi:ne180000]<char const*, std::__1::basic_format_parse_context<char>, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(char const*, char const*, std::__1::basic_format_parse_context<char>&, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>&)::'lambda'(char const*), std::__1::monostate&>(char const*&&, std::__1::monostate&) /b/my/build/libcxx_build_msan/include/c++/v1/__type_traits/invoke.h:344:25 #11 0xaaaacf5a0528 in std::__1::invoke_result<char const*, std::__1::monostate&>::type std::__1::invoke[abi:ne180000]<char const* std::__1::__format::__handle_replacement_field[abi:ne180000]<char const*, std::__1::basic_format_parse_context<char>, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(char const*, char const*, std::__1::basic_format_parse_context<char>&, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>&)::'lambda'(char const*), std::__1::monostate&>(char const*&&, std::__1::monostate&) /b/my/build/libcxx_build_msan/include/c++/v1/__functional/invoke.h:30:12 #12 0xaaaacf59f1d0 in decltype(auto) std::__1::__visit_format_arg[abi:ne180000]<char const* std::__1::__format::__handle_replacement_field[abi:ne180000]<char const*, std::__1::basic_format_parse_context<char>, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(char const*, char const*, std::__1::basic_format_parse_context<char>&, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>&)::'lambda'(char const*), std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(char const*&&, std::__1::basic_format_arg<std::__1::basic_format_parse_context<char>>) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_arg.h:103:12 #13 0xaaaacf59e6a0 in char const* std::__1::__format::__handle_replacement_field[abi:ne180000]<char const*, std::__1::basic_format_parse_context<char>, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(char const*, char const*, std::__1::basic_format_parse_context<char>&, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>&) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_functions.h:274:5 #14 0xaaaacf597f78 in std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>::iterator std::__1::__format::__vformat_to[abi:ne180000]<std::__1::basic_format_parse_context<char>, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>(std::__1::basic_format_parse_context<char>&&, std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>&&) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_functions.h:315:13 #15 0xaaaacf5978d4 in T std::__1::__vformat_to[abi:ne180000]<std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, char, std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>>(T, std::__1::locale, std::__1::basic_string_view<T0, std::__1::char_traits<T0>>, std::__1::basic_format_args<std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, T0>>) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_functions.h:552:5 #16 0xaaaacee00624 in std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>> std::__1::vformat_to[abi:ne180000]<std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>(std::__1::back_insert_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::locale, std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_format_args<std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_functions.h:562:10 #17 0xaaaacee00624 in std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> std::__1::vformat[abi:ne180000]<void>(std::__1::locale, std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_format_args<std::__1::basic_format_context<std::__1::back_insert_iterator<std::__1::__format::__output_buffer<char>>, char>>) /b/my/build/libcxx_build_msan/include/c++/v1/__format/format_functions.h:597:3 #18 0xaaaacee00624 in auto $_1::operator()<char>(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string_view<char, std::__1::char_traits<char>>) const /b/my/build/llvm-project/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp:42:7 #19 0xaaaacedea6b0 in void format_tests<char, (execution_modus)1, $_0, $_1>($_0, $_1) /b/my/build/llvm-project/libcxx/test/std/utilities/format/format.functions/format_tests.h:3148:3 #20 0xaaaacede80d0 in main /b/my/build/llvm-project/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp:54:3 #21 0xffffbed96dbc in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #22 0xffffbed96e94 in __libc_start_main csu/../csu/libc-start.c:360:3 #23 0xaaaaced5a02c in _start (/b/my/build/libcxx_build_msan/test/std/utilities/format/format.functions/Output/vformat.locale.pass.cpp.dir/t.tmp.exe+0x10a02c) MemorySanitizer can not provide additional info. SUMMARY: MemorySanitizer: ABRT nptl/pthread_kill.c:44:76 in __pthread_kill_implementation ==1128068==ABORTING ```