Skip to content

Commit a9f9165

Browse files
committed
[compiler-rt][rtsan] Use Die instead of exit
1 parent d6d6070 commit a9f9165

File tree

6 files changed

+38
-4
lines changed

6 files changed

+38
-4
lines changed

compiler-rt/lib/rtsan/rtsan_context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static __rtsan::Context &GetContextForThisThreadImpl() {
6262
Until then, and to keep the first PRs small, only the exit mode
6363
is available.
6464
*/
65-
static void InvokeViolationDetectedAction() { exit(EXIT_FAILURE); }
65+
static void InvokeViolationDetectedAction() { Die(); }
6666

6767
__rtsan::Context::Context() = default;
6868

compiler-rt/lib/rtsan/rtsan_flags.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void __rtsan::InitializeFlags() {
3535
{
3636
CommonFlags cf;
3737
cf.CopyFrom(*common_flags());
38+
cf.exitcode = 43; // (TR-)808 % 255 = 43
3839
cf.external_symbolizer_path = GetEnv("RTSAN_SYMBOLIZER_PATH");
3940
OverrideCommonFlags(cf);
4041
}

compiler-rt/lib/rtsan/tests/rtsan_test_main.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,25 @@
88
//
99
//===----------------------------------------------------------------------===//
1010

11+
#include "sanitizer_common/sanitizer_platform.h"
1112
#include "sanitizer_test_utils.h"
1213

14+
// Default RTSAN_OPTIONS for the unit tests.
15+
extern "C" const char *__rtsan_default_options() {
16+
#if SANITIZER_APPLE
17+
// On Darwin, we default to `abort_on_error=1`, which would make tests run
18+
// much slower. Let's override this and run lit tests with 'abort_on_error=0'
19+
// and make sure we do not overwhelm the syslog while testing. Also, let's
20+
// turn symbolization off to speed up testing, especially when not running
21+
// with llvm-symbolizer but with atos.
22+
return "symbolize=false:abort_on_error=0:log_to_syslog=0";
23+
#else
24+
// Let's turn symbolization off to speed up testing (more than 3 times speedup
25+
// observed).
26+
return "symbolize=false";
27+
#endif
28+
}
29+
1330
int main(int argc, char **argv) {
1431
testing::GTEST_FLAG(death_test_style) = "threadsafe";
1532
testing::InitGoogleTest(&argc, argv);

compiler-rt/lib/rtsan/tests/rtsan_test_utilities.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ void ExpectRealtimeDeath(Function &&Func,
3636
: "";
3737
};
3838

39-
EXPECT_EXIT(RealtimeInvoke(std::forward<Function>(Func)),
40-
ExitedWithCode(EXIT_FAILURE), GetExpectedErrorSubstring());
39+
EXPECT_EXIT(RealtimeInvoke(std::forward<Function>(Func)), ExitedWithCode(43),
40+
GetExpectedErrorSubstring());
4141
}
4242

4343
template <typename Function> void ExpectNonRealtimeSurvival(Function &&Func) {

compiler-rt/test/rtsan/basic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clangxx -fsanitize=realtime %s -o %t
2-
// RUN: not %run %t 2>&1 | FileCheck %s
2+
// RUN: %env_rtsan_opts=abort_on_error=0 not %run %t 2>&1 | FileCheck %s
33
// UNSUPPORTED: ios
44

55
// Intent: Ensure that an intercepted call in a [[clang::nonblocking]] function

compiler-rt/test/rtsan/lit.cfg.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
# Setup config name.
44
config.name = "RTSAN" + config.name_suffix
55

6+
7+
default_rtsan_opts = ""
8+
9+
if config.host_os == "Darwin":
10+
# On Darwin, we default to `abort_on_error=1`, which would make tests run
11+
# much slower. Let's override this and run lit tests with 'abort_on_error=0'.
12+
default_rtsan_opts += ":abort_on_error=0"
13+
14+
if default_rtsan_opts:
15+
config.environment["RTSAN_OPTIONS"] = default_rtsan_opts
16+
default_rtsan_opts += ":"
17+
18+
config.substitutions.append(
19+
("%env_rtsan_opts=", "env RTSAN_OPTIONS=" + default_rtsan_opts)
20+
)
21+
622
# Setup source root.
723
config.test_source_root = os.path.dirname(__file__)
824

0 commit comments

Comments
 (0)