Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,8 @@ if(asan)
set(ASAN_EXTRA_LD_PRELOAD "${CMAKE_BINARY_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}ROOTSanitizerConfig${CMAKE_SHARED_LIBRARY_SUFFIX}:${ASAN_RUNTIME_LIBRARY}")
endif()

foreach(item IN LISTS ASAN_EXTRA_CXX_FLAGS)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${item}>)
endforeach()
#add_link_options() not available in our CMake version:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ASAN_EXTRA_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ASAN_EXTRA_CXX_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${ASAN_EXTRA_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${ASAN_EXTRA_EXE_LINKER_FLAGS}")
endif()
Expand Down Expand Up @@ -731,6 +729,28 @@ if(LLVM_LINKER_IS_MOLD)
endif()
endif()

if(asan)
# Now sanitize all executables that are not created with ROOT_EXECUTABLE()
# See core/sanitizer for details
function(sanitize_all_targets DIR_TO_SEARCH)
get_property(subdirs DIRECTORY "${DIR_TO_SEARCH}" PROPERTY SUBDIRECTORIES)
foreach(subdir IN LISTS subdirs)
sanitize_all_targets("${subdir}")
endforeach()

get_directory_property(directory_targets DIRECTORY "${DIR_TO_SEARCH}" BUILDSYSTEM_TARGETS)
foreach(target IN LISTS directory_targets)
get_target_property(target_type ${target} TYPE)
get_target_property(target_libs ${target} LINK_LIBRARIES)
if(target_type STREQUAL EXECUTABLE AND NOT target STREQUAL ROOTStaticSanitizerConfig AND NOT target_libs MATCHES "ROOTStaticSanitizerConfig")
target_link_libraries(${target} PRIVATE ROOTStaticSanitizerConfig)
message(VERBOSE "Adding sanitizer library to ${target} (not created via a ROOT macro): ${target_libs}")
endif()
endforeach()
endfunction()
sanitize_all_targets(${CMAKE_CURRENT_SOURCE_DIR})
endif()

cmake_host_system_information(RESULT PROCESSOR QUERY PROCESSOR_DESCRIPTION)

message(STATUS "ROOT Configuration \n
Expand Down
6 changes: 4 additions & 2 deletions bindings/pyroot/pythonizations/src/RPyROOTApplication.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ bool PyROOT::RPyROOTApplication::CreateApplication(int ignoreCmdLineOpts)
char **argv = nullptr;

if (ignoreCmdLineOpts) {
argv = new char *[argc];
// Last argv must be null (see https://en.cppreference.com/cpp/language/main_function)
argv = new char *[argc + 1]{};
} else {
// Retrieve sys.argv list from Python
PyObject *argl = PySys_GetObject("argv");
Expand All @@ -57,7 +58,8 @@ bool PyROOT::RPyROOTApplication::CreateApplication(int ignoreCmdLineOpts)
argc = static_cast<int>(size);
}

argv = new char *[argc];
// Last argv must be null (see https://en.cppreference.com/cpp/language/main_function)
argv = new char *[argc + 1]{};

for (int i = 1; i < argc; ++i) {
PyObject *item = PyList_GetItem(argl, i);
Expand Down
1 change: 1 addition & 0 deletions bindings/pyroot/pythonizations/test/import_load_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class ImportLoadLibs(unittest.TestCase):
"libatomic",
# AddressSanitizer runtime and ROOT configuration
"libclang_rt.asan-.*",
"libasan",
"libROOTSanitizerConfig",
"libjitterentropy", # by libssl on openSUSE
"libsandbox", # Gentoo portage test environment
Expand Down
1 change: 0 additions & 1 deletion builtins/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ if(MSVC)
if(NOT winrtdebug)
set(gtestbuild "RelWithDebInfo")
endif()
set(GTEST_CXX_FLAGS "${ROOT_EXTERNAL_CXX_FLAGS} ${ASAN_EXTRA_CXX_FLAGS}")
endif()
set(EXTRA_GTEST_OPTS
-DCMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/RootBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ option(rootbench "Build rootbench if rootbench exists in root or if it is a sibl
option(roottest "Build roottest (implies testing=ON)" OFF)
option(test_roofit_hs3testsuite "Setup and use the HS3 conformance test suite (requires network)" OFF)
option(testing "Enable testing with CTest" OFF)
option(asan "Build ROOT with address sanitizer instrumentation (only GCC is currently supported)" OFF)
option(asan "Build ROOT with address sanitizer instrumentation (see core/sanitizer for details)" OFF)
option(_wheel_build "ROOT is being packaged as a wheel, do not install .dist-info metadata" OFF)

set(gcctoolchain "" CACHE PATH "Set path to GCC toolchain used to build llvm/clang")
Expand Down
4 changes: 1 addition & 3 deletions cmake/modules/RootConfiguration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,7 @@ else()
# Needed by ACLIC, while in ROOT we are using everywhere C++ standard via CMake features that are requested to build target
set(CMAKE_CXX_ACLIC_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION}")
if(asan)
# Replace the semicolon with space so that the produced compiler invokation still makes sense
string (REPLACE ";" " " ASAN_EXTRA_CXX_FLAGS_STR "${ASAN_EXTRA_CXX_FLAGS}")
set(CMAKE_CXX_ACLIC_FLAGS "${CMAKE_CXX_ACLIC_FLAGS} ${ASAN_EXTRA_CXX_FLAGS_STR}")
set(CMAKE_CXX_ACLIC_FLAGS "${CMAKE_CXX_ACLIC_FLAGS} ${ASAN_EXTRA_CXX_FLAGS}")
endif()
if(ROOT_COMPILEDATA_IGNORE_BUILD_NODE_CHANGES)
# Only set the compiledata parameter if the CMake variable is 'true'
Expand Down
28 changes: 8 additions & 20 deletions cmake/modules/RootMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1477,9 +1477,9 @@ function(ROOT_EXECUTABLE executable)
endif()
endforeach()
endif()
if(TARGET ROOT::ROOTStaticSanitizerConfig)
if(TARGET ROOTStaticSanitizerConfig)
set_property(TARGET ${executable}
APPEND PROPERTY LINK_LIBRARIES ROOT::ROOTStaticSanitizerConfig)
APPEND PROPERTY LINK_LIBRARIES ROOTStaticSanitizerConfig)
endif()
#----Installation details------------------------------------------------------
if(NOT ARG_NOINSTALL AND CMAKE_RUNTIME_OUTPUT_DIRECTORY)
Expand Down Expand Up @@ -2872,19 +2872,13 @@ macro(ROOTTEST_GENERATE_EXECUTABLE executable)
set(libraries ${libraries} ${library})
endif()
endforeach()
target_link_libraries(${executable} ${libraries})
target_link_libraries(${executable} PUBLIC ${libraries})
else()
target_link_libraries(${executable} ${ARG_LIBRARIES})
target_link_libraries(${executable} PUBLIC ${ARG_LIBRARIES})
endif()
endif()
if(MSVC AND DEFINED ROOT_SOURCE_DIR)
if(TARGET ROOTStaticSanitizerConfig)
target_link_libraries(${executable} ROOTStaticSanitizerConfig)
endif()
else()
if(TARGET ROOT::ROOTStaticSanitizerConfig)
target_link_libraries(${executable} ROOT::ROOTStaticSanitizerConfig)
endif()
if(TARGET ROOTStaticSanitizerConfig)
target_link_libraries(${executable} PRIVATE ROOTStaticSanitizerConfig)
endif()

if(ARG_COMPILE_FLAGS)
Expand Down Expand Up @@ -3493,14 +3487,8 @@ function(ROOTTEST_ADD_UNITTEST_DIR)
target_link_libraries(${binary} PRIVATE GTest::gtest GTest::gtest_main ${libraries})
set_property(TARGET ${binary} PROPERTY BUILD_WITH_INSTALL_RPATH OFF) # will never be installed anyway

if(MSVC AND DEFINED ROOT_SOURCE_DIR)
if(TARGET ROOTStaticSanitizerConfig)
target_link_libraries(${binary} ROOTStaticSanitizerConfig)
endif()
else()
if(TARGET ROOT::ROOTStaticSanitizerConfig)
target_link_libraries(${binary} PRIVATE ROOT::ROOTStaticSanitizerConfig)
endif()
if(TARGET ROOTStaticSanitizerConfig)
target_link_libraries(${binary} PRIVATE ROOTStaticSanitizerConfig)
endif()

# Mark the test as known to fail.
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/SetUpFreeBSD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
if(asan)
# See also core/sanitizer/README.md for what's happening.
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan-x86_64.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-recover=address)
set(ASAN_EXTRA_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize-recover=address")
set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address -z undefs")
set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -z undefs -Wl,--undefined=__asan_default_options -Wl,--undefined=__lsan_default_options -Wl,--undefined=__lsan_default_suppressions")
endif()
Expand All @@ -97,7 +97,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
if(ASAN_RUNTIME_LIBRARY STREQUAL "libclang_rt.asan-x86_64.so")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope)
set(ASAN_EXTRA_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope")
set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address -static-libsan -z undefs")
set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -static-libsan -z undefs -Wl,--undefined=__asan_default_options -Wl,--undefined=__lsan_default_options -Wl,--undefined=__lsan_default_suppressions")
endif()
Expand Down
21 changes: 14 additions & 7 deletions cmake/modules/SetUpLinux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ if(CMAKE_COMPILER_IS_GNUCXX)

if(asan)
# See also core/sanitizer/README.md for what's happening.
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan-x86_64.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-recover=address)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=libasan.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT EXISTS "${ASAN_RUNTIME_LIBRARY}")
message(WARNING "'${ASAN_RUNTIME_LIBRARY}' does not seem to be a valid sanitizer library. ROOT's Python tests cannot be sanitised.")
endif()
set(ASAN_EXTRA_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope")
set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address -z undefs")
set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -z undefs -Wl,--undefined=__asan_default_options -Wl,--undefined=__lsan_default_options -Wl,--undefined=__lsan_default_suppressions")
endif()
Expand All @@ -105,12 +108,16 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)

if(asan)
# See also core/sanitizer/README.md for what's happening.
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan-x86_64.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE)
# Since a while now, Clang installs libclang_rt.asan.so in an architecture dependent directory.
if(ASAN_RUNTIME_LIBRARY STREQUAL "libclang_rt.asan-x86_64.so")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan.so OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE)
foreach(libname libclang_rt.asan-x86_64.so libclang_rt.asan.so)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=${libname} OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE)
if(EXISTS ${ASAN_RUNTIME_LIBRARY})
break()
endif()
endforeach()
if(NOT EXISTS "${ASAN_RUNTIME_LIBRARY}")
message(WARNING "'${ASAN_RUNTIME_LIBRARY}' does not seem to be a valid sanitizer library. ROOT's Python tests cannot be sanitized.")
endif()
set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope)
set(ASAN_EXTRA_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope")
set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address -static-libsan -z undefs")
set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -static-libsan -z undefs -Wl,--undefined=__asan_default_options -Wl,--undefined=__lsan_default_options -Wl,--undefined=__lsan_default_suppressions")
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/SetUpMacOS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if (CMAKE_SYSTEM_NAME MATCHES Darwin)
if(asan)
# See also core/sanitizer/README.md for what's happening.
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.asan_osx_dynamic.dylib OUTPUT_VARIABLE ASAN_RUNTIME_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ASAN_EXTRA_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope)
set(ASAN_EXTRA_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope")
set(ASAN_EXTRA_SHARED_LINKER_FLAGS "-fsanitize=address")
set(ASAN_EXTRA_EXE_LINKER_FLAGS "-fsanitize=address -Wl,-U,__asan_default_options -Wl,-U,__lsan_default_options -Wl,-U,__lsan_default_suppressions")
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/SetUpWindows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ elseif(MSVC)
endif()

if(asan)
set(ASAN_EXTRA_CXX_FLAGS /fsanitize=address /wd5072)
set(ASAN_EXTRA_CXX_FLAGS "/fsanitize=address /wd5072")
set(ASAN_EXTRA_SHARED_LINKER_FLAGS "/InferASanLibs /incremental:no /DEBUG")
set(ASAN_EXTRA_EXE_LINKER_FLAGS "/InferASanLibs /incremental:no /DEBUG")
endif()
Expand Down
7 changes: 0 additions & 7 deletions core/sanitizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,3 @@ target_link_libraries(${library} INTERFACE ${ASAN_EXTRA_EXE_LINKER_FLAGS})
# Make it visible to the outside to sanitize e.g. roottest executables
set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS ${library})
add_library(ROOT::${library} ALIAS ${library})

# Now sanitize executables that are not created with ROOT_EXECUTABLE():
foreach(target llvm-min-tblgen llvm-tblgen clang-tblgen cppinterop-tblgen)
if(TARGET ${target})
target_link_libraries(${target} PRIVATE ${library})
endif()
endforeach()
5 changes: 1 addition & 4 deletions graf2d/graf/src/TLatex.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1778,10 +1778,7 @@ TLatex::TLatexFormSize TLatex::Analyse(Double_t x, Double_t y, const TextSpec_t
return TLatexFormSize(0,0,0);
}
TextSpec_t newSpec = spec;
Char_t *url = new Char_t[opSquareCurly-opUrl-4];
strncpy(url,text+opUrl+5,opSquareCurly-opUrl-5);
fName = url;
delete[] url;
fName = TString(text + opUrl + 5, opSquareCurly - opUrl - 5);
if (!fShow) {
result = Anal1(newSpec,text+opSquareCurly+1,length-opSquareCurly-1);
} else {
Expand Down
3 changes: 0 additions & 3 deletions interpreter/cling/tools/plugins/clad/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ if(MSVC AND NOT CMAKE_GENERATOR MATCHES Ninja)
else()
set(_clad_build_type Release)
endif()
if(asan)
set(CLAD_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ASAN_EXTRA_CXX_FLAGS}")
endif()
set(EXTRA_BUILD_ARGS --config ${_clad_build_type})
endif()
if(NOT _clad_build_type STREQUAL "" AND NOT _clad_build_type STREQUAL ".")
Expand Down
3 changes: 3 additions & 0 deletions math/mathcore/inc/Math/CladDerivator.h
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ extern "C" void sgemm_(const char *transa, const char *transb, const int *m, con

namespace clad::custom_derivatives {

#ifdef R__HAS_TMVACPU
namespace TMVA::Experimental::SOFIE {

inline void Gemm_Call_pullback(float *output, bool transa, bool transb, int m, int n, int k, float alpha,
Expand Down Expand Up @@ -1156,6 +1157,8 @@ inline void Relu_pullback(float *output, const float *input, int size, float *_d

} // namespace TMVA::Experimental::SOFIE

#endif // R__HAS_TMVACPU

} // namespace clad::custom_derivatives

#endif // CLAD_DERIVATOR
Loading