diff options
author | AlexSm <alex@ydb.tech> | 2024-03-05 10:40:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-05 12:40:59 +0300 |
commit | 1ac13c847b5358faba44dbb638a828e24369467b (patch) | |
tree | 07672b4dd3604ad3dee540a02c6494cb7d10dc3d /util/system/sanitizers.cpp | |
parent | ffcca3e7f7958ddc6487b91d3df8c01054bd0638 (diff) | |
download | ydb-1ac13c847b5358faba44dbb638a828e24369467b.tar.gz |
Library import 16 (#2433)
Co-authored-by: robot-piglet <robot-piglet@yandex-team.com>
Co-authored-by: deshevoy <deshevoy@yandex-team.com>
Co-authored-by: robot-contrib <robot-contrib@yandex-team.com>
Co-authored-by: thegeorg <thegeorg@yandex-team.com>
Co-authored-by: robot-ya-builder <robot-ya-builder@yandex-team.com>
Co-authored-by: svidyuk <svidyuk@yandex-team.com>
Co-authored-by: shadchin <shadchin@yandex-team.com>
Co-authored-by: robot-ratatosk <robot-ratatosk@yandex-team.com>
Co-authored-by: innokentii <innokentii@yandex-team.com>
Co-authored-by: arkady-e1ppa <arkady-e1ppa@yandex-team.com>
Co-authored-by: snermolaev <snermolaev@yandex-team.com>
Co-authored-by: dimdim11 <dimdim11@yandex-team.com>
Co-authored-by: kickbutt <kickbutt@yandex-team.com>
Co-authored-by: abdullinsaid <abdullinsaid@yandex-team.com>
Co-authored-by: korsunandrei <korsunandrei@yandex-team.com>
Co-authored-by: petrk <petrk@yandex-team.com>
Co-authored-by: miroslav2 <miroslav2@yandex-team.com>
Co-authored-by: serjflint <serjflint@yandex-team.com>
Co-authored-by: akhropov <akhropov@yandex-team.com>
Co-authored-by: prettyboy <prettyboy@yandex-team.com>
Co-authored-by: ilikepugs <ilikepugs@yandex-team.com>
Co-authored-by: hiddenpath <hiddenpath@yandex-team.com>
Co-authored-by: mikhnenko <mikhnenko@yandex-team.com>
Co-authored-by: spreis <spreis@yandex-team.com>
Co-authored-by: andreyshspb <andreyshspb@yandex-team.com>
Co-authored-by: dimaandreev <dimaandreev@yandex-team.com>
Co-authored-by: rashid <rashid@yandex-team.com>
Co-authored-by: robot-ydb-importer <robot-ydb-importer@yandex-team.com>
Co-authored-by: r-vetrov <r-vetrov@yandex-team.com>
Co-authored-by: ypodlesov <ypodlesov@yandex-team.com>
Co-authored-by: zaverden <zaverden@yandex-team.com>
Co-authored-by: vpozdyayev <vpozdyayev@yandex-team.com>
Co-authored-by: robot-cozmo <robot-cozmo@yandex-team.com>
Co-authored-by: v-korovin <v-korovin@yandex-team.com>
Co-authored-by: arikon <arikon@yandex-team.com>
Co-authored-by: khoden <khoden@yandex-team.com>
Co-authored-by: psydmm <psydmm@yandex-team.com>
Co-authored-by: robot-javacom <robot-javacom@yandex-team.com>
Co-authored-by: dtorilov <dtorilov@yandex-team.com>
Co-authored-by: sennikovmv <sennikovmv@yandex-team.com>
Co-authored-by: hcpp <hcpp@ydb.tech>
Diffstat (limited to 'util/system/sanitizers.cpp')
-rw-r--r-- | util/system/sanitizers.cpp | 83 |
1 files changed, 8 insertions, 75 deletions
diff --git a/util/system/sanitizers.cpp b/util/system/sanitizers.cpp index bb799a9e2e..3e710b39c7 100644 --- a/util/system/sanitizers.cpp +++ b/util/system/sanitizers.cpp @@ -1,42 +1,29 @@ #include "sanitizers.h" #include "thread.h" -#if defined(_asan_enabled_) -extern "C" { - void __sanitizer_start_switch_fiber(void** fake_stack_save, const void* bottom, size_t size); - void __sanitizer_finish_switch_fiber(void* fake_stack_save, const void** old_bottom, size_t* old_size); -} -#endif +using namespace NSan; #if defined(_tsan_enabled_) #if defined(__clang_major__) && (__clang_major__ >= 9) -extern "C" { - void* __tsan_get_current_fiber(void); +extern "C" { // sanitizers API + + #if defined(_tsan_enabled_) void* __tsan_create_fiber(unsigned flags); - void __tsan_destroy_fiber(void* fiber); - void __tsan_switch_to_fiber(void* fiber, unsigned flags); void __tsan_set_fiber_name(void* fiber, const char* name); -} + #endif + +} // sanitizers API #else namespace { - void* __tsan_get_current_fiber(void) { - return nullptr; - } void* __tsan_create_fiber(unsigned) { return nullptr; } - void __tsan_destroy_fiber(void*) { - } - void __tsan_switch_to_fiber(void*, unsigned) { - } void __tsan_set_fiber_name(void*, const char*) { } } #endif #endif -using namespace NSan; - TFiberContext::TFiberContext() noexcept : Token_(nullptr) , IsMainFiber_(true) @@ -45,7 +32,7 @@ TFiberContext::TFiberContext() noexcept #endif { TCurrentThreadLimits sl; - + (void)Token_; Stack_ = sl.StackBegin; Len_ = sl.StackLength; @@ -70,60 +57,6 @@ TFiberContext::TFiberContext(const void* stack, size_t len, const char* contName #endif } -TFiberContext::~TFiberContext() noexcept { - if (!IsMainFiber_) { -#if defined(_asan_enabled_) - if (Token_) { - // destroy saved FakeStack - void* activeFakeStack = nullptr; - const void* activeStack = nullptr; - size_t activeStackSize = 0; - __sanitizer_start_switch_fiber(&activeFakeStack, (char*)Stack_, Len_); - __sanitizer_finish_switch_fiber(Token_, &activeStack, &activeStackSize); - __sanitizer_start_switch_fiber(nullptr, activeStack, activeStackSize); - __sanitizer_finish_switch_fiber(activeFakeStack, nullptr, nullptr); - } -#endif -#if defined(_tsan_enabled_) - __tsan_destroy_fiber(CurrentTSanFiberContext_); -#endif - } -} - -void TFiberContext::BeforeFinish() noexcept { -#if defined(_asan_enabled_) - __sanitizer_start_switch_fiber(nullptr, nullptr, 0); -#else - (void)Token_; - (void)Stack_; - (void)Len_; -#endif -} - -void TFiberContext::BeforeSwitch(TFiberContext* old) noexcept { -#if defined(_asan_enabled_) - __sanitizer_start_switch_fiber(old ? &old->Token_ : nullptr, (char*)Stack_, Len_); -#else - (void)old; -#endif - -#if defined(_tsan_enabled_) - __tsan_switch_to_fiber(CurrentTSanFiberContext_, /*flags =*/0); -#endif -} - -void TFiberContext::AfterSwitch() noexcept { -#if defined(_asan_enabled_) - __sanitizer_finish_switch_fiber(Token_, nullptr, nullptr); -#endif -} - -void TFiberContext::AfterStart() noexcept { -#if defined(_asan_enabled_) - __sanitizer_finish_switch_fiber(nullptr, nullptr, nullptr); -#endif -} - #if defined(_tsan_enabled_) extern "C" { // This function should not be directly exposed in headers |