From bb6a5ebe80950dc6c69b121746542a9db07ebbe9 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 26 May 2021 23:27:06 +0200 Subject: [PATCH] tsan: add TSAN options file to set some default flags and exclude some libs from checks --- lib/include/srsran/common/tsan_options.h | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 lib/include/srsran/common/tsan_options.h diff --git a/lib/include/srsran/common/tsan_options.h b/lib/include/srsran/common/tsan_options.h new file mode 100644 index 000000000..96a4f2544 --- /dev/null +++ b/lib/include/srsran/common/tsan_options.h @@ -0,0 +1,49 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2021 Software Radio Systems Limited + * + * By using this file, you agree to the terms and conditions set + * forth in the LICENSE file which can be found at the top level of + * the distribution. + * + */ + +#ifndef SRSRAN_TSAN_OPTIONS_H +#define SRSRAN_TSAN_OPTIONS_H + +// Options taken from Mozilla project +// abort_on_error=1 - Causes TSan to abort instead of using exit(). +// halt_on_error=1 - Causes TSan to stop on the first race detected. +// +// report_signal_unsafe=0 - Required to avoid TSan deadlocks when +// receiving external signals (e.g. SIGINT manually on console). +// +// allocator_may_return_null=1 - Tell TSan to return NULL when an allocation +// fails instead of aborting the program. This allows us to handle failing +// allocations the same way we would handle them with a regular allocator and +// also uncovers potential bugs that might occur in these situations. + +#ifdef __cplusplus +extern "C" { +#endif + +const char* __tsan_default_options() +{ + return "halt_on_error=1:abort_on_error=1:report_signal_unsafe=0" + ":allocator_may_return_null=1"; +} + +const char* __tsan_default_suppressions() +{ + // External uninstrumented libraries + return "called_from_lib:libzmq.so\n" + "called_from_lib:libpgm-5.2.so\n"; +} + +#ifdef __cplusplus +} +#endif + +#endif // SRSRAN_TSAN_OPTIONS_H