diff --git a/compiler-rt/lib/radsan/CMakeLists.txt b/compiler-rt/lib/radsan/CMakeLists.txt index 1cff9be14e272..c7d1dacf3dbc7 100644 --- a/compiler-rt/lib/radsan/CMakeLists.txt +++ b/compiler-rt/lib/radsan/CMakeLists.txt @@ -4,8 +4,7 @@ set(RADSAN_CXX_SOURCES radsan.cpp radsan_context.cpp radsan_stack.cpp - radsan_interceptors.cpp - radsan_user_interface.cpp) + radsan_interceptors.cpp) set(RADSAN_PREINIT_SOURCES radsan_preinit.cpp) diff --git a/compiler-rt/lib/radsan/radsan_context.cpp b/compiler-rt/lib/radsan/radsan_context.cpp index 1407fb38782aa..1fabb8c4894e1 100644 --- a/compiler-rt/lib/radsan/radsan_context.cpp +++ b/compiler-rt/lib/radsan/radsan_context.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -29,10 +30,7 @@ void internalFree(void *ptr) { InternalFree(ptr); } namespace radsan { -Context::Context() : Context(createErrorActionGetter()) {} - -Context::Context(std::function get_error_action) - : get_error_action_(get_error_action) {} +Context::Context() = default; void Context::realtimePush() { realtime_depth_++; } @@ -46,10 +44,10 @@ void Context::expectNotRealtime(const char *intercepted_function_name) { if (inRealtimeContext() && !isBypassed()) { bypassPush(); printDiagnostics(intercepted_function_name); - if (get_error_action_() == OnErrorAction::ExitWithFailure) { - exit(EXIT_FAILURE); - } - bypassPop(); + + // TODO: re-implement "continue" with normal sanitizer options + exit(EXIT_FAILURE); + // bypassPop(); } } diff --git a/compiler-rt/lib/radsan/radsan_context.h b/compiler-rt/lib/radsan/radsan_context.h index ca2f0c5735e32..66d810ce97735 100644 --- a/compiler-rt/lib/radsan/radsan_context.h +++ b/compiler-rt/lib/radsan/radsan_context.h @@ -8,16 +8,11 @@ #pragma once -#include - -#include - namespace radsan { class Context { public: Context(); - Context(std::function get_error_action); void realtimePush(); void realtimePop(); @@ -34,7 +29,6 @@ class Context { int realtime_depth_{0}; int bypass_depth_{0}; - std::function get_error_action_; }; Context &getContextForThisThread(); diff --git a/compiler-rt/lib/radsan/radsan_user_interface.cpp b/compiler-rt/lib/radsan/radsan_user_interface.cpp deleted file mode 100644 index 39d26c94b3b20..0000000000000 --- a/compiler-rt/lib/radsan/radsan_user_interface.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/** - This file is part of the RealtimeSanitizer (RADSan) project. - https://github.com/realtime-sanitizer/radsan - - Copyright 2023 David Trevelyan & Alistair Barker - Subject to GNU General Public License (GPL) v3.0 -*/ - -#include -#include - -#include - -#include -#include -#include - -namespace radsan { - -std::function createErrorActionGetter() { - auto const continue_getter = []() { return OnErrorAction::Continue; }; - auto const exit_getter = []() { return OnErrorAction::ExitWithFailure; }; - auto const interactive_getter = []() { - auto response = char{}; - - std::cout << "Continue? (Y/n): "; - std::cin >> std::noskipws >> response; - - if (std::toupper(response) == 'N') - return OnErrorAction::ExitWithFailure; - else - return OnErrorAction::Continue; - }; - - auto user_mode = __sanitizer::GetEnv("RADSAN_ERROR_MODE"); - if (user_mode == nullptr) { - return exit_getter; - } - - if (std::strcmp(user_mode, "interactive") == 0) { - return interactive_getter; - } - - if (std::strcmp(user_mode, "continue") == 0) { - return continue_getter; - } - - if (std::strcmp(user_mode, "exit") == 0) { - return exit_getter; - } - - return exit_getter; -} - -} // namespace radsan diff --git a/compiler-rt/lib/radsan/radsan_user_interface.h b/compiler-rt/lib/radsan/radsan_user_interface.h deleted file mode 100644 index 231d3f37740a8..0000000000000 --- a/compiler-rt/lib/radsan/radsan_user_interface.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -namespace radsan { - -enum class OnErrorAction { - Continue, - ExitWithFailure, -}; - -std::function createErrorActionGetter(); - -} diff --git a/compiler-rt/lib/radsan/tests/radsan_test_context.cpp b/compiler-rt/lib/radsan/tests/radsan_test_context.cpp index 4ff1c37e04be8..e974a71aa4731 100644 --- a/compiler-rt/lib/radsan/tests/radsan_test_context.cpp +++ b/compiler-rt/lib/radsan/tests/radsan_test_context.cpp @@ -9,7 +9,6 @@ #include "radsan_test_utilities.h" #include "radsan_context.h" -#include "radsan_user_interface.h" TEST(TestRadsanContext, canCreateContext) { auto context = radsan::Context{}; } @@ -68,14 +67,4 @@ TEST(TestRadsanContext, } TEST(TestRadsanContext, onlyDiesIfExitWithFailureReturnedFromUser) { - auto fake_action = radsan::OnErrorAction::Continue; - auto action_getter = [&fake_action]() { return fake_action; }; - - auto context = radsan::Context{action_getter}; - context.realtimePush(); - - context.expectNotRealtime("do_some_stuff_expecting_continue"); - - fake_action = radsan::OnErrorAction::ExitWithFailure; - EXPECT_DEATH(context.expectNotRealtime("do_some_stuff_expecting_exit"), ""); } diff --git a/compiler-rt/test/radsan/TestCases/test_continue_mode.cpp b/compiler-rt/test/radsan/TestCases/test_continue_mode.cpp index 0eb6ccb1aaa90..858252b9263d9 100644 --- a/compiler-rt/test/radsan/TestCases/test_continue_mode.cpp +++ b/compiler-rt/test/radsan/TestCases/test_continue_mode.cpp @@ -1,5 +1,5 @@ // RUN: %clangxx -fsanitize=realtime %s -o %t -// RUN: env RADSAN_ERROR_MODE=continue %run %t 2>&1 | FileCheck %s +// RUN: not env %run %t 2>&1 | FileCheck %s // UNSUPPORTED: ios // Intent: Ensure that Continue mode does not exit on the first violation. @@ -8,6 +8,7 @@ // aka "not env RADSAN_ERROR_MODE=continue %run %t 2>&1 | FileCheck %s" // but running in continue mode does not exit non-zero // https://trello.com/c/vNaKEFty/66-running-in-mode-continue-does-not-exit-non-zero-to-indicate-error +// This test doesn't even currently support "continue mode" because of the c fiasco #include @@ -29,5 +30,4 @@ int main() { return 0; // CHECK: {{.*Real-time violation.*}} // CHECK: {{.*malloc*}} - // CHECK: {{.*free*}} }