Skip to content

Commit

Permalink
[GHA] Enable thread sanitizer (openvinotoolkit#26634)
Browse files Browse the repository at this point in the history
### Details:
 - Enable thread sanitizer
 - Fixed protobuf build

### Tickets:
 - *ticket-id*
  • Loading branch information
mryzhov authored Oct 18, 2024
1 parent 03c9ae3 commit 373cf90
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 116 deletions.
234 changes: 122 additions & 112 deletions .github/workflows/linux_sanitizers.yml

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions cmake/developer_package/compile_flags/sanitizer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (ENABLE_SANITIZER)
"https://github.com/openvinotoolkit/openvino/wiki/AddressSanitizer-and-LeakSanitizer")
endif()
elseif(OV_COMPILER_IS_CLANG)
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=address -fsanitize-blacklist=${OpenVINO_SOURCE_DIR}/tests/asan/ignore.txt")
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=address -fsanitize-blacklist=${OpenVINO_SOURCE_DIR}/tests/sanitizers/asan/ignore.txt")
if(BUILD_SHARED_LIBS)
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -shared-libasan")
endif()
Expand All @@ -27,7 +27,7 @@ if (ENABLE_SANITIZER)
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=address")
endif()

set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=address -fsanitize-blacklist=${OpenVINO_SOURCE_DIR}/tests/asan/ignore.txt")
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=address -fsanitize-blacklist=${OpenVINO_SOURCE_DIR}/tests/sanitizers/asan/ignore.txt")
if(BUILD_SHARED_LIBS)
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -shared-libasan")
endif()
Expand Down Expand Up @@ -89,7 +89,11 @@ if(ENABLE_THREAD_SANITIZER)
message(FATAL_ERROR "Thread sanitizer is not supported in Windows with MSVC compiler. Please, use clang-cl or mingw")
elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=thread")
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=thread")
if(OV_COMPILER_IS_CLANG)
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -ltsan")
else()
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=thread")
endif()
else()
message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}")
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "exception.hpp"
#include "openvino/core/any.hpp"
#include "openvino/frontend/node_context.hpp"
#include "openvino/frontend/tensorflow/visibility.hpp"
#include "variable.hpp"
#include "variables_map.hpp"

Expand All @@ -18,7 +19,7 @@ class TranslateSession;

/// Keep necessary data for a single node in the original FW graph to facilitate
/// conversion process in the rules code.
class NodeContext : public ov::frontend::NodeContext {
class TENSORFLOW_API NodeContext : public ov::frontend::NodeContext {
public:
using Ptr = std::shared_ptr<NodeContext>;
NodeContext(const std::shared_ptr<DecoderBase>& decoder,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions tests/sanitizers/tsan/suppressions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

# This is a ThreadSanitizer (TSan) suppression file which provides a default
# configuration for the builds with -DENABLE_SANITIZER=ON.
# More information about LSan suppressions on
# https://github.com/google/sanitizers/wiki/threadsanitizersuppressions

# race conditions from thirdparty libs
race:libtbb
mutex:libtbb
race:libhwloc
# race conditions from std libs
race:libstdc++
race:libc
9 changes: 9 additions & 0 deletions thirdparty/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,15 @@ if(ENABLE_OV_PADDLE_FRONTEND OR ENABLE_OV_ONNX_FRONTEND OR ENABLE_OV_TF_FRONTEND
endif()
else()
add_subdirectory(thirdparty/protobuf EXCLUDE_FROM_ALL)
# protobuf fails to build with -fsanitize=thread by clang
if(ENABLE_THREAD_SANITIZER AND OV_COMPILER_IS_CLANG)
foreach(proto_target protoc libprotobuf libprotobuf-lite)
if(TARGET ${proto_target})
target_compile_options(${proto_target} PUBLIC -fno-sanitize=thread)
target_link_options(${proto_target} PUBLIC -fno-sanitize=thread)
endif()
endforeach()
endif()
endif()

# forward additional variables used in the other places
Expand Down

0 comments on commit 373cf90

Please sign in to comment.