Compare commits

..

7 Commits

Author SHA1 Message Date
Martin Hořeňovský
b25dff20c7 Try Intel Macos 15 2025-12-19 14:38:17 +01:00
Masashi Fujita
97091636d0 Fix conditional compilation for FreeBSD to exclude PlayStation platform 2025-12-12 09:38:52 +01:00
Martin Hořeňovský
f80956a43a Use magic statics for non-trivial thread-local globals
This avoids calling the global's constructor on threads that will
never interact with them. Calling the constructor can have surprising
overhead, as e.g. MSVC's Debug mode `std::vector` will allocate in
the default constructor.

Closes #3050
2025-12-02 14:19:21 +01:00
Martin Hořeňovský
32eac2d1bb Only use thread_local in builds with thread safety enabled
MSVC cannot dllexport thread_local variables, so we avoid making
globals thread local if we won't support multiple threads anyway.

Closes #3044
2025-12-02 14:01:55 +01:00
Martin Hořeňovský
e849735e11 Add tests for assertion thread safety 2025-12-01 10:45:07 +01:00
Martin Hořeňovský
d26f763180 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-12-01 10:44:31 +01:00
Martin Hořeňovský
5e44382423 Fix initialization of AtomicCounts for older standards 2025-12-01 10:42:43 +01:00
4 changed files with 9 additions and 45 deletions

View File

@@ -4,13 +4,11 @@ on: [push, pull_request]
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, macos-15]
image: [macos-15, macos-15-intel]
build_type: [Debug, Release]
std: [14, 17]

View File

@@ -1,36 +0,0 @@
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,7 +164,9 @@ namespace {
#if defined( CATCH_PLATFORM_LINUX ) \
|| defined( CATCH_PLATFORM_MAC ) \
|| defined( __GLIBC__ ) \
|| defined( __FreeBSD__ ) \
|| (defined( __FreeBSD__ ) \
/* PlayStation platform does not have `isatty()` */ \
&& !defined(CATCH_PLATFORM_PLAYSTATION)) \
|| 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 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 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).
// This is used for the "if" part of CHECKED_IF/CHECKED_ELSE
static CATCH_INTERNAL_THREAD_LOCAL bool g_lastAssertionPassed = false;