Compare commits

..

9 Commits

Author SHA1 Message Date
Martin Hořeňovský
036448b4b2 Undo magic-statification of message id counter 2025-12-02 10:51:42 +01:00
Martin Hořeňovský
24e305b83e Undo other trivial types away from functions 2025-12-01 23:21:33 +01:00
Martin Hořeňovský
15d4eb2ebe Keep g_lastAssertionPassed outside of function 2025-12-01 23:11:54 +01:00
Martin Hořeňovský
e075e04cde Use magic statics for thread-local globals 2025-12-01 22:23:51 +01:00
Martin Hořeňovský
d427034253 Only use thread_local in builds with thread safety enabled 2025-12-01 14:18:54 +01:00
Martin Hořeňovský
1e463608ef Test tsan on mac 2025-11-30 23:58:38 +01:00
Martin Hořeňovský
2c381a8819 Add tests for assertion thread safety 2025-11-30 23:58:31 +01:00
Martin Hořeňovský
32bf7b2330 Initialize ReusableStringStream cache before user threads can run
The initialization itself is thread unsafe, and as such we cannot
allow it to be delayed until multiple user-spawned threads need it.
2025-11-30 23:58:27 +01:00
Martin Hořeňovský
86267a7c6d Fix initialization of AtomicCounts for older standards 2025-11-30 23:42:20 +01:00
3 changed files with 42 additions and 8 deletions

36
.github/workflows/mac-other-builds.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: Mac Sanitizer Builds
on: [push, pull_request]
env:
CXXFLAGS: -fsanitize=thread,undefined
jobs:
build:
# From macos-14 forward, the baseline "macos-X" image is Arm based,
# and not Intel based.
runs-on: ${{matrix.image}}
strategy:
fail-fast: false
matrix:
image: [macos-13, macos-14]
build_type: [Debug, Release]
std: [14, 17]
steps:
- uses: actions/checkout@v4
- name: Configure
run: |
cmake --preset all-tests -GNinja \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCATCH_BUILD_EXTRA_TESTS=ON \
-DCATCH_ENABLE_WERROR=OFF
- name: Build
run: cmake --build build
- name: Test
run: ctest --test-dir build -R ThreadSafetyTests --timeout 21600 --verbose

View File

@@ -164,9 +164,7 @@ namespace {
#if defined( CATCH_PLATFORM_LINUX ) \
|| defined( CATCH_PLATFORM_MAC ) \
|| defined( __GLIBC__ ) \
|| (defined( __FreeBSD__ ) \
/* PlayStation platform does not have `isatty()` */ \
&& !defined(CATCH_PLATFORM_PLAYSTATION)) \
|| defined( __FreeBSD__ ) \
|| defined( CATCH_PLATFORM_QNX )
# define CATCH_INTERNAL_HAS_ISATTY
# include <unistd.h>

View File

@@ -175,11 +175,11 @@ namespace Catch {
// below, in the future we will want to allocate piece of memory
// from heap, to avoid consuming too much thread-local storage.
//
// Note that we also don't want non-trivial the thread-local variables
// below be initialized for every thread, only for those that touch
// Catch2. To make this work with both GCC/Clang and MSVC, we have to
// make them thread-local magic statics. (Class-level statics have the
// desired semantics on GCC, but not on MSVC).
// Note that we also don't want the thread-local variables below
// be initialized for every thread, only for those that touch Catch2.
// To make this work with both GCC/Clang and MSVC, we have to make
// them thread-local magic statics. (Class-level statics have
// the desired semantics on GCC, but not on MSVC).
// This is used for the "if" part of CHECKED_IF/CHECKED_ELSE
static CATCH_INTERNAL_THREAD_LOCAL bool g_lastAssertionPassed = false;