Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: build TSan with clang 15 and add -Werror=thread-safety, fix-up stacktraces #5375

Merged
merged 6 commits into from
May 26, 2023

Conversation

kwvg
Copy link
Collaborator

@kwvg kwvg commented May 17, 2023

Description

Pull request was inspired by the need to debug lock problems when working on #5352.

As far as I'm aware, only macOS has -Werror=thread-safety as part of its default CXXFLAGS despite the capability being present on Linux as well. This PR introduces thread safety checks for that into our thread sanitizer build.

Additionally, since we're using Clang, something that on first glimpse, appears to be something that stacktraces.cpp isn't happy with, due to -Wl,-wrap being available only on GCC, that no longer seems to be the case, since the version of Clang with comes with focal, its lld does have support for -wrap (see man page for lld on focal).

The current stable version of Clang/LLVM is 15, at the time of this pull request (see https://apt.llvm.org/) but focal ships with an older version, requiring us to use the official LLVM APT repository. I feel we should be testing with recent compilers alongside the ones shipped by LTS distributions.

Certain bugs are only made apparent when testing on rolling release distros or distros that have faster update cycles, like Fedora (see #5295 for an illustration of that), which ship with more recent compilers. Until we overhaul our CI systems to test using those distros directly (our current infrastructure is centered around using a "development image" with an LTS distro as the base), this is the best we can do.

A similar pull request testing against the latest GCC stable will be welcome as that is currently outside the scope of this PR as the changes made were to make sure that builds were operating as expected on Clang/LLVM 15.

@kwvg kwvg force-pushed the tsafety branch 6 times, most recently from cb0f27e to 0084613 Compare May 19, 2023 09:35
@kwvg kwvg marked this pull request as ready for review May 19, 2023 11:39
@kwvg kwvg requested review from UdjinM6 and PastaPastaPasta May 19, 2023 11:39
@kwvg kwvg changed the title ci: build TSan with clang 15 and add -Werror=thread-safety ci: build TSan with clang 15 and add -Werror=thread-safety, fix-up stacktraces May 19, 2023
#if __clang__
#error not supported on WIN32 (no dlsym support)
#elif WIN32
#if WIN32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, feels like these changes should be in another PR? This PR should just be adding clang-15 and thread-safety

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixes for stacktraces are directly aimed to resolve problems with a Clang/LLVM target, which didn't exist in our CI suite until this PR, so it was retained here. The changes weren't significant enough to warrant its own PR and aren't verifiable without this PR's merger (sans stracktrace changes)

@kwvg kwvg requested a review from PastaPastaPasta May 21, 2023 05:54
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get no useful info in debug.log on failed ASSERT_IF_DEBUGs anymore (on macos). 6424d78 broke it.

develop:

Assertion failure:
  assertion: (pCycleQuorumBaseBlockIndex->nHeight % llmqParams.dkgInterval == 2) 
  file: utils.cpp, line: 68 
  function: GetHashModifier 

this PR:

Posix Signal: Abort trap: 6

Reverting it https://gitlab.com/UdjinM6/dash/-/commit/aa051f96eb2053ea95f021d07c67b7995c6e518f helps but it breaks CI. Applying https://gitlab.com/UdjinM6/dash/-/commit/dfb27a9d6767921f59701b20d92834cb918d62a2 or https://gitlab.com/UdjinM6/dash/-/commit/a0fde69efe98a8c499900f8e3bd87634b33fd06d on top makes CI happy (and it still works on macos too).

@kwvg
Copy link
Collaborator Author

kwvg commented May 25, 2023

Changes integrated in latest push!

@kwvg kwvg requested a review from UdjinM6 May 25, 2023 08:21
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, utACK

kwvg and others added 6 commits May 26, 2023 13:45
Clang's warnings are far noisier and warnings about deprecations and the
like from our dependencies are out of our control (and with dependencies
like Boost, clog up the build log to the point GitLab stops logging)
`#elifdef` is introduced since C++23 but we target at most, C++17 and
since a lot of conditional logic relies on else statements that should
only check for presence rather than evaluate its value, it's better to
consistently use `#if defined(__MACRO__)` instead of `#ifdef __MACRO__`
for checking platform flags until the time we bump to C++23
Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK for squash merge

@PastaPastaPasta PastaPastaPasta merged commit 4963660 into dashpay:develop May 26, 2023
@UdjinM6 UdjinM6 added this to the 20 milestone May 30, 2023
knst added a commit to knst/dash that referenced this pull request Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants