Skip to content

Commit 373cf90

Browse files
authored
[GHA] Enable thread sanitizer (#26634)
### Details: - Enable thread sanitizer - Fixed protobuf build ### Tickets: - *ticket-id*
1 parent 03c9ae3 commit 373cf90

File tree

8 files changed

+155
-116
lines changed

8 files changed

+155
-116
lines changed

.github/workflows/linux_sanitizers.yml

+122-112
Large diffs are not rendered by default.

cmake/developer_package/compile_flags/sanitizer.cmake

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (ENABLE_SANITIZER)
1717
"https://github.com/openvinotoolkit/openvino/wiki/AddressSanitizer-and-LeakSanitizer")
1818
endif()
1919
elseif(OV_COMPILER_IS_CLANG)
20-
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=address -fsanitize-blacklist=${OpenVINO_SOURCE_DIR}/tests/asan/ignore.txt")
20+
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=address -fsanitize-blacklist=${OpenVINO_SOURCE_DIR}/tests/sanitizers/asan/ignore.txt")
2121
if(BUILD_SHARED_LIBS)
2222
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -shared-libasan")
2323
endif()
@@ -27,7 +27,7 @@ if (ENABLE_SANITIZER)
2727
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize-recover=address")
2828
endif()
2929

30-
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=address -fsanitize-blacklist=${OpenVINO_SOURCE_DIR}/tests/asan/ignore.txt")
30+
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=address -fsanitize-blacklist=${OpenVINO_SOURCE_DIR}/tests/sanitizers/asan/ignore.txt")
3131
if(BUILD_SHARED_LIBS)
3232
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -shared-libasan")
3333
endif()
@@ -89,7 +89,11 @@ if(ENABLE_THREAD_SANITIZER)
8989
message(FATAL_ERROR "Thread sanitizer is not supported in Windows with MSVC compiler. Please, use clang-cl or mingw")
9090
elseif(CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG)
9191
set(SANITIZER_COMPILER_FLAGS "${SANITIZER_COMPILER_FLAGS} -fsanitize=thread")
92-
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=thread")
92+
if(OV_COMPILER_IS_CLANG)
93+
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -ltsan")
94+
else()
95+
set(SANITIZER_LINKER_FLAGS "${SANITIZER_LINKER_FLAGS} -fsanitize=thread")
96+
endif()
9397
else()
9498
message(WARNING "Unsupported CXX compiler ${CMAKE_CXX_COMPILER_ID}")
9599
endif()

src/frontends/tensorflow/include/openvino/frontend/tensorflow/node_context.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "exception.hpp"
99
#include "openvino/core/any.hpp"
1010
#include "openvino/frontend/node_context.hpp"
11+
#include "openvino/frontend/tensorflow/visibility.hpp"
1112
#include "variable.hpp"
1213
#include "variables_map.hpp"
1314

@@ -18,7 +19,7 @@ class TranslateSession;
1819

1920
/// Keep necessary data for a single node in the original FW graph to facilitate
2021
/// conversion process in the rules code.
21-
class NodeContext : public ov::frontend::NodeContext {
22+
class TENSORFLOW_API NodeContext : public ov::frontend::NodeContext {
2223
public:
2324
using Ptr = std::shared_ptr<NodeContext>;
2425
NodeContext(const std::shared_ptr<DecoderBase>& decoder,
File renamed without changes.
File renamed without changes.
File renamed without changes.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (C) 2018-2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# This is a ThreadSanitizer (TSan) suppression file which provides a default
5+
# configuration for the builds with -DENABLE_SANITIZER=ON.
6+
# More information about LSan suppressions on
7+
# https://github.com/google/sanitizers/wiki/threadsanitizersuppressions
8+
9+
# race conditions from thirdparty libs
10+
race:libtbb
11+
mutex:libtbb
12+
race:libhwloc
13+
# race conditions from std libs
14+
race:libstdc++
15+
race:libc

thirdparty/dependencies.cmake

+9
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,15 @@ if(ENABLE_OV_PADDLE_FRONTEND OR ENABLE_OV_ONNX_FRONTEND OR ENABLE_OV_TF_FRONTEND
357357
endif()
358358
else()
359359
add_subdirectory(thirdparty/protobuf EXCLUDE_FROM_ALL)
360+
# protobuf fails to build with -fsanitize=thread by clang
361+
if(ENABLE_THREAD_SANITIZER AND OV_COMPILER_IS_CLANG)
362+
foreach(proto_target protoc libprotobuf libprotobuf-lite)
363+
if(TARGET ${proto_target})
364+
target_compile_options(${proto_target} PUBLIC -fno-sanitize=thread)
365+
target_link_options(${proto_target} PUBLIC -fno-sanitize=thread)
366+
endif()
367+
endforeach()
368+
endif()
360369
endif()
361370

362371
# forward additional variables used in the other places

0 commit comments

Comments
 (0)