[compiler-rt] [rtsan][compiler-rt] Introduce __rtsan_notify_blocking_call (PR #109529)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 23 11:57:50 PDT 2024


zeroomega wrote:

> [1527/1693](33) Linking CXX shared library /Volumes/Work/s/w/ir/x/w/llvm_build/lib/clang/20/lib/darwin/libclang_rt.rtsan_osx_dynamic.dylib
>  FAILED: /Volumes/Work/s/w/ir/x/w/llvm_build/lib/clang/20/lib/darwin/libclang_rt.rtsan_osx_dynamic.dylib 
>  : && /Volumes/Work/s/w/ir/x/w/llvm_build/./bin/clang++ --target=x86_64-apple-darwin22.6.0 --sysroot=/Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffile-prefix-map=/Volumes/Work/s/w/ir/x/w/llvm_build/runtimes/runtimes-bins=../../../llvm-llvm-project -ffile-prefix-map=/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes -Wall -Wno-unused-parameter -O3 -DNDEBUG -arch arm64 -arch x86_64 -isysroot /Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -dynamiclib -Wl,-headerpad_max_install_names -fuse-ld=lld -Wl,--color-diagnostics   -stdlib=libc++ -lc++ -lc++abi -fapplication-extension -mmacosx-version-min=10.13 -isysroot /Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -nodefaultlibs -Wl,-U,___sanitizer_free_hook -Wl,-U,___sanitizer_get_dtls_size -Wl,-U,___sanitizer_malloc_hook -Wl,-U,___sanitizer_report_error_summary -Wl,-U,___sanitizer_sandbox_on_notify -Wl,-U,___sanitizer_symbolize_code -Wl,-U,___sanitizer_symbolize_data -Wl,-U,___sanitizer_symbolize_frame -Wl,-U,___sanitizer_symbolize_demangle -Wl,-U,___sanitizer_symbolize_flush -Wl,-U,___sanitizer_symbolize_set_demangle -Wl,-U,___sanitizer_symbolize_set_inline_frames -o /Volumes/Work/s/w/ir/x/w/llvm_build/lib/clang/20/lib/darwin/libclang_rt.rtsan_osx_dynamic.dylib -install_name @rpath/libclang_rt.rtsan_osx_dynamic.dylib compiler-rt/lib/rtsan/CMakeFiles/RTRtsan.osx.dir/rtsan.cpp.o compiler-rt/lib/rtsan/CMakeFiles/RTRtsan.osx.dir/rtsan_assertions.cpp.o compiler-rt/lib/rtsan/CMakeFiles/RTRtsan.osx.dir/rtsan_context.cpp.o compiler-rt/lib/rtsan/CMakeFiles/RTRtsan.osx.dir/rtsan_diagnostics.cpp.o compiler-rt/lib/rtsan/CMakeFiles/RTRtsan.osx.dir/rtsan_flags.cpp.o compiler-rt/lib/rtsan/CMakeFiles/RTRtsan.osx.dir/rtsan_interceptors.cpp.o compiler-rt/lib/interception/CMakeFiles/RTInterception.osx.dir/interception_linux.cpp.o compiler-rt/lib/interception/CMakeFiles/RTInterception.osx.dir/interception_mac.cpp.o compiler-rt/lib/interception/CMakeFiles/RTInterception.osx.dir/interception_win.cpp.o compiler-rt/lib/interception/CMakeFiles/RTInterception.osx.dir/interception_type_test.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_allocator.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_common.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_deadlock_detector1.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_deadlock_detector2.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_errno.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_file.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_flags.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_flag_parser.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_fuchsia.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_libc.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_libignore.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_linux.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_linux_s390.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_mac.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_mutex.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_netbsd.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_freebsd.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_linux.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_netbsd.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_posix.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_solaris.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_posix.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_printf.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_common.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_bsd.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_fuchsia.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_linux.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_mac.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_solaris.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_range.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_solaris.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_stoptheworld_fuchsia.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_stoptheworld_mac.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_stoptheworld_win.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_suppressions.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_tls_get_addr.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_thread_arg_retval.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_thread_registry.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_type_traits.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_win.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_win_interception.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_termination.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_common_libcdep.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_allocator_checks.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_dl.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_linux_libcdep.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_mac_libcdep.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_posix_libcdep.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_stoptheworld_linux_libcdep.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_stoptheworld_netbsd_libcdep.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.osx.dir/sancov_flags.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.osx.dir/sanitizer_coverage_fuchsia.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.osx.dir/sanitizer_coverage_libcdep_new.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonCoverage.osx.dir/sanitizer_coverage_win_sections.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_allocator_report.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_chained_origin_depot.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_stack_store.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_stackdepot.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_stacktrace.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_stacktrace_libcdep.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_stacktrace_printer.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_stacktrace_sparc.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_libbacktrace.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_libcdep.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_mac.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_markup.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_markup_fuchsia.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_posix_libcdep.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_report.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_report_fuchsia.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_win.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_unwind_linux_libcdep.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_unwind_fuchsia.cpp.o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_unwind_win.cpp.o  -ldl  -lm  -lpthread && cd /Volumes/Work/s/w/ir/x/w/llvm_build/lib/clang/20/lib/darwin && codesign --sign - -o linker-signed /Volumes/Work/s/w/ir/x/w/llvm_build/lib/clang/20/lib/darwin/libclang_rt.rtsan_osx_dynamic.dylib
>  clang++: warning: argument unused during compilation: '-stdlib=libc++' [-Wunused-command-line-argument]
>  ld64.lld: error: undefined symbol for arch arm64: std::__2::__libcpp_verbose_abort(char const*, ...)
>  >>> referenced by variant:313 (/Volumes/Work/s/w/ir/x/w/llvm_build/./bin/../include/c++/v1/variant:313)
>  >>>               compiler-rt/lib/rtsan/CMakeFiles/RTRtsan.osx.dir/rtsan_diagnostics.cpp.o:(symbol std::__2::__throw_bad_variant_access[abi:nn200000]()+0x10)
>  >>> did you mean: std::__1::__libcpp_verbose_abort(char const*, ...)
>  >>> defined in: /Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/lib/libc++.tbd(/usr/lib/libc++.1.dylib)
>  clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Emmm, we also looked into this issue on our end and we don't think the root cause is mixture of v1 and v2 ABI in the build environment. We set the `LIBCXX_ABI_VERSION` to `2` and provide a v2 libcxx in our toolchain. The issue is likely that rtsan now uses a libcxx fuction but it didn't link against the libcxx in the same build ( could be a missing dependency in the build file). In this case, the linker is trying to link rtsan agaist host libcxx. And in this build failure, the host libcxx is from XCode SDK and it doesn't have v2 ABI. I think in order to properly fix this issue, we should fix the rtsan's build file by plumb through the libcxx in the same build, so the rtsan will be link against the libcxx from the same build, which has the v2 ABI. 

This issue did't show up before, probably due to the fact that rtsan didn't use any libcxx feature so missing dependency did cause any issue. 

https://github.com/llvm/llvm-project/pull/109529


More information about the llvm-commits mailing list