Skip to content

Commit 990b2bc

Browse files
committed
Revert "ci: build TSan with clang 15 and add -Werror=thread-safety, fix-up stacktraces (dashpay#5375)"
This reverts commit 4963660.
1 parent c7dec85 commit 990b2bc

File tree

3 files changed

+27
-38
lines changed

3 files changed

+27
-38
lines changed

ci/test/00_setup_env_native_tsan.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export DEP_OPTS="NO_UPNP=1 DEBUG=1"
1212
export TEST_RUNNER_EXTRA="--extended --exclude feature_pruning,feature_dbcrash,wallet_multiwallet.py" # Temporarily suppress ASan heap-use-after-free (see issue #14163)
1313
export GOAL="install"
1414
export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --with-sanitizers=thread"
15-
export BITCOIN_CONFIG="${BITCOIN_CONFIG} CC=clang-15 CXX=clang++-15 CXXFLAGS=-Werror=thread-safety"
1615
export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG"
1716
export PYZMQ=true
1817
export RUN_SYMBOL_TESTS=false

contrib/containers/ci/Dockerfile

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ RUN apt-get update && apt-get install $APT_ARGS \
111111
valgrind \
112112
wine-stable \
113113
wine64 \
114-
xorriso
114+
xorriso \
115+
&& rm -rf /var/lib/apt/lists/*
115116

116117
ARG CPPCHECK_VERSION=2.10
117118
RUN curl -sL "https://github.com/danmar/cppcheck/archive/${CPPCHECK_VERSION}.tar.gz" | tar -xvzf - --directory /tmp/
@@ -135,20 +136,6 @@ RUN \
135136
update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix; \
136137
exit 0
137138

138-
ARG LLVM_VERSION=15
139-
# Setup Clang+LLVM support
140-
RUN apt-get update && apt-get install $APT_ARGS \
141-
lsb-release \
142-
software-properties-common \
143-
gnupg \
144-
&& rm -rf /var/lib/apt/lists/*
145-
146-
RUN cd /tmp && \
147-
wget https://apt.llvm.org/llvm.sh && \
148-
chmod +x llvm.sh && \
149-
/tmp/llvm.sh ${LLVM_VERSION} && \
150-
rm -rf /tmp/llvm.sh
151-
152139
RUN \
153140
mkdir -p /src/dash && \
154141
mkdir -p /cache/ccache && \

src/stacktraces.cpp

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <memory>
1919
#include <atomic>
2020

21-
#if defined(WIN32)
21+
#if WIN32
2222
#include <windows.h>
2323
#include <dbghelp.h>
2424
#include <thread>
@@ -30,14 +30,14 @@
3030
#include <csignal>
3131
#endif
3232

33-
#if !defined(WIN32)
33+
#if !WIN32
3434
#include <dlfcn.h>
35-
#if !defined(__APPLE__)
35+
#if !__APPLE__
3636
#include <link.h>
3737
#endif
3838
#endif
3939

40-
#if defined(__APPLE__)
40+
#if __APPLE__
4141
#include <mach-o/dyld.h>
4242
#include <mach/mach_init.h>
4343
#include <sys/sysctl.h>
@@ -52,7 +52,7 @@
5252

5353
std::string DemangleSymbol(const std::string& name)
5454
{
55-
#if defined(__GNUC__) || defined(__clang__)
55+
#if __GNUC__ || __clang__
5656
int status = -4; // some arbitrary value to eliminate the compiler warning
5757
char* str = abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status);
5858
if (status != 0) {
@@ -74,7 +74,7 @@ static std::atomic<bool> skipAbortSignal(false);
7474

7575
static ssize_t GetExeFileNameImpl(char* buf, size_t bufSize)
7676
{
77-
#if defined(WIN32)
77+
#if WIN32
7878
std::vector<TCHAR> tmp(bufSize);
7979
DWORD len = GetModuleFileName(nullptr, tmp.data(), bufSize);
8080
if (len >= bufSize) {
@@ -84,7 +84,7 @@ static ssize_t GetExeFileNameImpl(char* buf, size_t bufSize)
8484
buf[i] = (char)tmp[i];
8585
}
8686
return len;
87-
#elif defined(__APPLE__)
87+
#elif __APPLE__
8888
uint32_t bufSize2 = (uint32_t)bufSize;
8989
if (_NSGetExecutablePath(buf, &bufSize2) != 0) {
9090
// it's not entirely clear if the value returned by _NSGetExecutablePath includes the null character
@@ -127,7 +127,7 @@ static void my_backtrace_error_callback (void *data, const char *msg,
127127

128128
static backtrace_state* GetLibBacktraceState()
129129
{
130-
#if defined(WIN32)
130+
#if WIN32
131131
// libbacktrace is not able to handle the DWARF debuglink in the .exe
132132
// but luckily we can just specify the .dbg file here as it's a valid PE/XCOFF file
133133
static std::string debugFileName = g_exeFileName + ".dbg";
@@ -140,7 +140,7 @@ static backtrace_state* GetLibBacktraceState()
140140
}
141141
#endif // ENABLE_STACKTRACES
142142

143-
#if defined(WIN32)
143+
#if WIN32
144144
static uint64_t GetBaseAddress()
145145
{
146146
return 0;
@@ -188,15 +188,15 @@ static __attribute__((noinline)) std::vector<uint64_t> GetStackFrames(size_t ski
188188
STACKFRAME64 stackframe;
189189
ZeroMemory(&stackframe, sizeof(STACKFRAME64));
190190

191-
#if defined(__i386__)
191+
#ifdef __i386__
192192
image = IMAGE_FILE_MACHINE_I386;
193193
stackframe.AddrPC.Offset = context.Eip;
194194
stackframe.AddrPC.Mode = AddrModeFlat;
195195
stackframe.AddrFrame.Offset = context.Ebp;
196196
stackframe.AddrFrame.Mode = AddrModeFlat;
197197
stackframe.AddrStack.Offset = context.Esp;
198198
stackframe.AddrStack.Mode = AddrModeFlat;
199-
#elif defined(__x86_64__)
199+
#elif __x86_64__
200200
image = IMAGE_FILE_MACHINE_AMD64;
201201
stackframe.AddrPC.Offset = context.Rip;
202202
stackframe.AddrPC.Mode = AddrModeFlat;
@@ -240,7 +240,7 @@ static __attribute__((noinline)) std::vector<uint64_t> GetStackFrames(size_t ski
240240
}
241241
#else
242242

243-
#if defined(__APPLE__)
243+
#if __APPLE__
244244
static uint64_t GetBaseAddress()
245245
{
246246
mach_port_name_t target_task;
@@ -534,11 +534,14 @@ static void PrintCrashInfo(const crash_info& ci)
534534
static StdMutex g_stacktraces_mutex;
535535
static std::map<void*, std::shared_ptr<std::vector<uint64_t>>> g_stacktraces;
536536

537-
#ifdef CRASH_HOOKS_WRAPPED_CXX_ABI
537+
#if CRASH_HOOKS_WRAPPED_CXX_ABI
538538
// These come in through -Wl,-wrap
539+
// It only works on GCC
539540
extern "C" void* __real___cxa_allocate_exception(size_t thrown_size);
540541
extern "C" void __real___cxa_free_exception(void * thrown_exception);
541-
#if defined(WIN32)
542+
#if __clang__
543+
#error not supported on WIN32 (no dlsym support)
544+
#elif WIN32
542545
extern "C" void __real__assert(const char *assertion, const char *file, unsigned int line);
543546
extern "C" void __real__wassert(const wchar_t *assertion, const wchar_t *file, unsigned int line);
544547
#else
@@ -557,13 +560,13 @@ extern "C" void __real___cxa_free_exception(void * thrown_exception)
557560
static auto f = (void(*)(void*))dlsym(RTLD_NEXT, "__cxa_free_exception");
558561
return f(thrown_exception);
559562
}
560-
#if defined(__clang__) && defined(__APPLE__)
563+
#if __clang__
561564
extern "C" void __attribute__((noreturn)) __real___assert_rtn(const char *function, const char *file, int line, const char *assertion)
562565
{
563566
static auto f = (void(__attribute__((noreturn)) *) (const char*, const char*, int, const char*))dlsym(RTLD_NEXT, "__assert_rtn");
564567
f(function, file, line, assertion);
565568
}
566-
#elif defined(WIN32)
569+
#elif WIN32
567570
#error not supported on WIN32 (no dlsym support)
568571
#else
569572
extern "C" void __real___assert_fail(const char *assertion, const char *file, unsigned int line, const char *function)
@@ -574,7 +577,7 @@ extern "C" void __real___assert_fail(const char *assertion, const char *file, un
574577
#endif
575578
#endif
576579

577-
#ifdef CRASH_HOOKS_WRAPPED_CXX_ABI
580+
#if CRASH_HOOKS_WRAPPED_CXX_ABI
578581
#define WRAPPED_NAME(x) __wrap_##x
579582
#else
580583
#define WRAPPED_NAME(x) x
@@ -622,15 +625,15 @@ static __attribute__((noinline)) crash_info GetCrashInfoFromAssertion(const char
622625
return ci;
623626
}
624627

625-
#if defined(__clang__) && defined(__APPLE__)
628+
#if __clang__
626629
extern "C" void __attribute__((noinline)) WRAPPED_NAME(__assert_rtn)(const char *function, const char *file, int line, const char *assertion)
627630
{
628631
auto ci = GetCrashInfoFromAssertion(assertion, file, line, function);
629632
PrintCrashInfo(ci);
630633
skipAbortSignal = true;
631634
__real___assert_rtn(function, file, line, assertion);
632635
}
633-
#elif defined(WIN32)
636+
#elif WIN32
634637
extern "C" void __attribute__((noinline)) WRAPPED_NAME(_assert)(const char *assertion, const char *file, unsigned int line)
635638
{
636639
auto ci = GetCrashInfoFromAssertion(assertion, file, line, nullptr);
@@ -760,7 +763,7 @@ void RegisterPrettyTerminateHander()
760763
std::set_terminate(terminate_handler);
761764
}
762765

763-
#if !defined(WIN32)
766+
#if !WIN32
764767
static void HandlePosixSignal(int s)
765768
{
766769
if (s == SIGABRT && skipAbortSignal) {
@@ -837,7 +840,7 @@ LONG WINAPI HandleWindowsException(EXCEPTION_POINTERS * ExceptionInfo)
837840

838841
void RegisterPrettySignalHandlers()
839842
{
840-
#if defined(WIN32)
843+
#if WIN32
841844
SetUnhandledExceptionFilter(HandleWindowsException);
842845
#else
843846
const std::vector<int> posix_signals = {
@@ -853,7 +856,7 @@ void RegisterPrettySignalHandlers()
853856
SIGTRAP, // Trace/breakpoint trap
854857
SIGXCPU, // CPU time limit exceeded (4.2BSD)
855858
SIGXFSZ, // File size limit exceeded (4.2BSD)
856-
#if defined(__APPLE__)
859+
#if __APPLE__
857860
SIGEMT, // emulation instruction executed
858861
#endif
859862
};

0 commit comments

Comments
 (0)