[libcxx] [llvm] speculative attempt to fix what might be configuration race condition (PR #146157)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 29 08:34:55 PDT 2025


https://github.com/EricWF updated https://github.com/llvm/llvm-project/pull/146157

>From ad3594173f7a94378a88e500874023e00cfd5cb4 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Fri, 27 Jun 2025 17:12:27 -0400
Subject: [PATCH 01/19] speculative attempt to fix what might be configuration
 race condition

---
 libcxx/test/benchmarks/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/test/benchmarks/CMakeLists.txt b/libcxx/test/benchmarks/CMakeLists.txt
index b0fe600623d96..6237572657638 100644
--- a/libcxx/test/benchmarks/CMakeLists.txt
+++ b/libcxx/test/benchmarks/CMakeLists.txt
@@ -30,7 +30,7 @@ endif()
 
 ExternalProject_Add(google-benchmark
         EXCLUDE_FROM_ALL ON
-        DEPENDS cxx cxx-headers
+        DEPENDS cxx cxx-headers install-cxx-test-suite-prefix
         PREFIX google-benchmark
         SOURCE_DIR ${LLVM_THIRD_PARTY_DIR}/benchmark
         INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/google-benchmark

>From bb1e9a67d36f654b7eda8beebd85001f76ebc26d Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 11:50:12 -0400
Subject: [PATCH 02/19] temporarily disable benchmarks with tsan

---
 libcxx/cmake/caches/Generic-tsan.cmake | 1 +
 libcxx/test/benchmarks/CMakeLists.txt  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/libcxx/cmake/caches/Generic-tsan.cmake b/libcxx/cmake/caches/Generic-tsan.cmake
index c42c1bb8e7222..de4a76d7842ea 100644
--- a/libcxx/cmake/caches/Generic-tsan.cmake
+++ b/libcxx/cmake/caches/Generic-tsan.cmake
@@ -1,2 +1,3 @@
 set(LLVM_USE_SANITIZER "Thread" CACHE STRING "")
 set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "") # TSAN is compiled against the system unwinder, which leads to false positives
+set(LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "FIXME: This is a temporary workaround to get tsan running again")
\ No newline at end of file
diff --git a/libcxx/test/benchmarks/CMakeLists.txt b/libcxx/test/benchmarks/CMakeLists.txt
index 6237572657638..b0fe600623d96 100644
--- a/libcxx/test/benchmarks/CMakeLists.txt
+++ b/libcxx/test/benchmarks/CMakeLists.txt
@@ -30,7 +30,7 @@ endif()
 
 ExternalProject_Add(google-benchmark
         EXCLUDE_FROM_ALL ON
-        DEPENDS cxx cxx-headers install-cxx-test-suite-prefix
+        DEPENDS cxx cxx-headers
         PREFIX google-benchmark
         SOURCE_DIR ${LLVM_THIRD_PARTY_DIR}/benchmark
         INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/google-benchmark

>From 78b66bb164fec6cad9f9c8c90c6e0f2e487912b8 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 11:53:07 -0400
Subject: [PATCH 03/19] disable all but tsan

---
 .github/workflows/libcxx-build-and-test.yaml | 236 +------------------
 1 file changed, 4 insertions(+), 232 deletions(-)

diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index f0bdf6c0b5899..b79dd941f08b2 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -34,201 +34,22 @@ concurrency:
   cancel-in-progress: true
 
 jobs:
-  stage1:
-    if: github.repository_owner == 'llvm'
-    runs-on: libcxx-self-hosted-linux
-    container: ghcr.io/llvm/libcxx-linux-builder:b060022103f551d8ca1dad84122ef73927c86512
-    continue-on-error: false
-    strategy:
-      fail-fast: false
-      matrix:
-        config: [
-          'frozen-cxx03-headers',
-          'generic-cxx03',
-          'generic-cxx26',
-          'generic-modules'
-        ]
-        cc: [  'clang-21' ]
-        cxx: [ 'clang++-21' ]
-        include:
-          - config: 'generic-gcc'
-            cc: 'gcc-15'
-            cxx: 'g++-15'
-    steps:
-      - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
-      - name: ${{ matrix.config }}.${{ matrix.cxx }}
-        run: libcxx/utils/ci/run-buildbot ${{ matrix.config }}
-        env:
-          CC: ${{ matrix.cc }}
-          CXX: ${{ matrix.cxx }}
-      - uses: actions/upload-artifact at 26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
-        if: always()
-        with:
-          name: ${{ matrix.config }}-${{ matrix.cxx }}-results
-          path: |
-            **/test-results.xml
-            **/*.abilist
-            **/CMakeConfigureLog.yaml
-            **/CMakeError.log
-            **/CMakeOutput.log
-            **/crash_diagnostics/*
-  stage2:
-    if: github.repository_owner == 'llvm'
-    runs-on: libcxx-self-hosted-linux
-    container: ghcr.io/llvm/libcxx-linux-builder:2b57ebb50b6d418e70382e655feaa619b558e254
-    needs: [ stage1 ]
-    continue-on-error: false
-    strategy:
-      fail-fast: false
-      matrix:
-        config: [
-          'generic-cxx11',
-          'generic-cxx14',
-          'generic-cxx17',
-          'generic-cxx20',
-          'generic-cxx23'
-        ]
-        cc: [ 'clang-21' ]
-        cxx: [ 'clang++-21' ]
-        include:
-          - config: 'generic-gcc-cxx11'
-            cc: 'gcc-15'
-            cxx: 'g++-15'
-          - config: 'generic-cxx26'
-            cc: 'clang-20'
-            cxx: 'clang++-20'
-          - config: 'generic-cxx26'
-            cc: 'clang-19'
-            cxx: 'clang++-19'
-    steps:
-      - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
-      - name: ${{ matrix.config }}
-        run: libcxx/utils/ci/run-buildbot ${{ matrix.config }}
-        env:
-          CC: ${{ matrix.cc }}
-          CXX: ${{ matrix.cxx }}
-      - uses: actions/upload-artifact at 26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
-        if: always()  # Upload artifacts even if the build or test suite fails
-        with:
-          name: ${{ matrix.config }}-${{ matrix.cxx }}-results
-          path: |
-            **/test-results.xml
-            **/*.abilist
-            **/CMakeConfigureLog.yaml
-            **/CMakeError.log
-            **/CMakeOutput.log
-            **/crash_diagnostics/*
   stage3:
     if: github.repository_owner == 'llvm'
-    needs: [ stage2 ]
     continue-on-error: false
-    strategy:
-      fail-fast: false
-      max-parallel: 8
-      matrix:
-        config: [
-          'generic-abi-unstable',
-          'generic-hardening-mode-debug',
-          'generic-hardening-mode-extensive',
-          'generic-hardening-mode-fast',
-          'generic-hardening-mode-fast-with-abi-breaks',
-          'generic-merged',
-          'generic-modules-cxx17-lsv',
-          'generic-no-exceptions',
-          'generic-no-experimental',
-          'generic-no-filesystem',
-          'generic-no-localization',
-          'generic-no-terminal',
-          'generic-no-random_device',
-          'generic-no-threads',
-          'generic-no-tzdb',
-          'generic-no-unicode',
-          'generic-no-wide-characters',
-          'generic-no-rtti',
-          'generic-optimized-speed',
-          'generic-static',
-          'bootstrapping-build'
-        ]
-        machine: [ 'libcxx-self-hosted-linux' ]
-        include:
-        - config: 'generic-cxx26'
-          machine: libcxx-self-hosted-linux
-        - config: 'generic-asan'
-          machine: libcxx-self-hosted-linux
-        - config: 'generic-tsan'
-          machine: libcxx-self-hosted-linux
-        - config: 'generic-ubsan'
-          machine: libcxx-self-hosted-linux
-        # Use a larger machine for MSAN to avoid timeout and memory allocation issues.
-        - config: 'generic-msan'
-          machine: libcxx-self-hosted-linux
-    runs-on: ${{ matrix.machine }}
+    runs-on: libcxx-self-hosted-linux
     container: ghcr.io/llvm/libcxx-linux-builder:2b57ebb50b6d418e70382e655feaa619b558e254
     steps:
       - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
-      - name: ${{ matrix.config }}
-        run: libcxx/utils/ci/run-buildbot ${{ matrix.config }}
+      - name: generic-tsan
+        run: libcxx/utils/ci/run-buildbot generic-tsan
         env:
           CC: clang-21
           CXX: clang++-21
       - uses: actions/upload-artifact at 26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
         if: always()
         with:
-          name: ${{ matrix.config }}-results
-          path: |
-            **/test-results.xml
-            **/*.abilist
-            **/CMakeConfigureLog.yaml
-            **/CMakeError.log
-            **/CMakeOutput.log
-            **/crash_diagnostics/*
-
-  macos:
-    needs: [ stage2 ]
-    strategy:
-      fail-fast: false
-      matrix:
-        include:
-        - config: generic-cxx03
-          os: macos-15
-        - config: generic-cxx23
-          os: macos-15
-        - config: generic-modules
-          os: macos-15
-        - config: apple-configuration
-          os: macos-15
-        # TODO: These jobs are intended to test back-deployment (building against ToT libc++ but running against an
-        #       older system-provided libc++.dylib). Doing this properly would require building the test suite on a
-        #       recent macOS using a recent Clang (hence recent Xcode), and then running the actual test suite on an
-        #       older mac. We could do that by e.g. sharing artifacts between the two jobs.
-        #
-        #       However, our Lit configuration currently doesn't provide a good way to do that in a batch, so our only
-        #       alternative is to actually build on the same host that we're going to run on. Sadly, that doesn't work
-        #       since older macOSes don't support newer Xcodes. For now, we run the "backdeployment" jobs on recent
-        #       macOS versions as a way to avoid rotting that configuration, but it doesn't provide a lot of additional
-        #       coverage.
-        - config: apple-system
-          os: macos-15
-        - config: apple-system-hardened
-          os: macos-15
-    runs-on: ${{ matrix.os }}
-    steps:
-      - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
-      - uses: maxim-lobanov/setup-xcode at 60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
-        with:
-          # https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
-          xcode-version: '16.3'
-      - uses: seanmiddleditch/gha-setup-ninja at 3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # v6
-      - name: Build and test
-        run: |
-          python3 -m venv .venv
-          source .venv/bin/activate
-          python -m pip install psutil
-          bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}
-      - uses: actions/upload-artifact at 26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
-        if: always()  # Upload artifacts even if the build or test suite fails
-        with:
-          name: macos-${{ matrix.config }}-results
+          name: generic-tsan-results
           path: |
             **/test-results.xml
             **/*.abilist
@@ -237,52 +58,3 @@ jobs:
             **/CMakeOutput.log
             **/crash_diagnostics/*
 
-  windows:
-    runs-on: windows-2022
-    needs: [ stage2 ]
-    strategy:
-      fail-fast: false
-      matrix:
-        include:
-        - { config: clang-cl-dll, mingw: false }
-        - { config: clang-cl-static, mingw: false }
-        - { config: clang-cl-no-vcruntime, mingw: false }
-        - { config: clang-cl-debug, mingw: false }
-        - { config: clang-cl-static-crt, mingw: false }
-        - { config: mingw-dll, mingw: true }
-        - { config: mingw-static, mingw: true }
-        - { config: mingw-dll-i686, mingw: true }
-        - { config: mingw-incomplete-sysroot, mingw: true }
-    steps:
-      - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
-      - name: Install dependencies
-        run: |
-          choco install -y ninja
-          pip install psutil
-      - name: Install a current LLVM
-        if: ${{ matrix.mingw != true }}
-        run: |
-          choco install -y llvm --version=19.1.7 --allow-downgrade
-      - name: Install llvm-mingw
-        if: ${{ matrix.mingw == true }}
-        run: |
-          curl -LO https://github.com/mstorsjo/llvm-mingw/releases/download/20250114/llvm-mingw-20250114-ucrt-x86_64.zip
-          powershell Expand-Archive llvm-mingw*.zip -DestinationPath .
-          del llvm-mingw*.zip
-          mv llvm-mingw* c:\llvm-mingw
-          echo "c:\llvm-mingw\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
-      - name: Simulate a from-scratch build of llvm-mingw
-        if: ${{ matrix.config == 'mingw-incomplete-sysroot' }}
-        run: |
-          rm -r c:\llvm-mingw\include\c++
-          rm -r c:\llvm-mingw\*-w64-mingw32\lib\libc++*
-          rm -r c:\llvm-mingw\*-w64-mingw32\lib\libunwind*
-      - name: Add Git Bash to the path
-        run: |
-          echo "c:\Program Files\Git\usr\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
-      - name: Set up the MSVC dev environment
-        if: ${{ matrix.mingw != true }}
-        uses: ilammy/msvc-dev-cmd at 0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
-      - name: Build and test
-        run: |
-          bash libcxx/utils/ci/run-buildbot ${{ matrix.config }}

>From c8fc4fa48507efef4b1a96c486e1b21a76831192 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 12:10:57 -0400
Subject: [PATCH 04/19] try setting mmap settings

---
 .github/workflows/libcxx-build-and-test.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index b79dd941f08b2..6872d5aa16f3f 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -42,7 +42,7 @@ jobs:
     steps:
       - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
       - name: generic-tsan
-        run: libcxx/utils/ci/run-buildbot generic-tsan
+        run: sudo sysctl vm.mmap_rnd_bits=30 && libcxx/utils/ci/run-buildbot generic-tsan
         env:
           CC: clang-21
           CXX: clang++-21

>From be4b8e94431c668c72583223f1bb1a26bc3caf37 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 12:26:47 -0400
Subject: [PATCH 05/19] try fudging with more flags

---
 .github/workflows/libcxx-build-and-test.yaml | 2 +-
 libcxx/utils/libcxx/test/params.py           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index 6872d5aa16f3f..7318bef43e9f0 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -42,7 +42,7 @@ jobs:
     steps:
       - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
       - name: generic-tsan
-        run: sudo sysctl vm.mmap_rnd_bits=30 && libcxx/utils/ci/run-buildbot generic-tsan
+        run: sudo sysctl vm.mmap_rnd_bits=32; libcxx/utils/ci/run-buildbot generic-tsan
         env:
           CC: clang-21
           CXX: clang++-21
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index fc34009d0a551..8c34b588aec4e 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -330,7 +330,7 @@ def getSuitableClangTidy(cfg):
                 AddFeature("msan")                         if sanitizer in ["Memory", "MemoryWithOrigins"] else None,
                 AddFlag("-fsanitize-memory-track-origins") if sanitizer == "MemoryWithOrigins" else None,
 
-                AddFlag("-fsanitize=thread") if sanitizer == "Thread" else None,
+                AddFlag("-fsanitize=thread -fno-sanitize-recover=all -g -O1") if sanitizer == "Thread" else None,
                 AddFeature("tsan")           if sanitizer == "Thread" else None,
 
                 AddFlag("-fsanitize=dataflow") if sanitizer == "DataFlow" else None,

>From d79c900387fefaa37d6b7137d208452d7635ee5d Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 12:53:05 -0400
Subject: [PATCH 06/19] remove redundant flags

---
 libcxx/utils/libcxx/test/params.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 8c34b588aec4e..e187ffa44a9e5 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -330,7 +330,7 @@ def getSuitableClangTidy(cfg):
                 AddFeature("msan")                         if sanitizer in ["Memory", "MemoryWithOrigins"] else None,
                 AddFlag("-fsanitize-memory-track-origins") if sanitizer == "MemoryWithOrigins" else None,
 
-                AddFlag("-fsanitize=thread -fno-sanitize-recover=all -g -O1") if sanitizer == "Thread" else None,
+                AddFlag("-fsanitize=thread -fno-sanitize-recover=all  -O1") if sanitizer == "Thread" else None,
                 AddFeature("tsan")           if sanitizer == "Thread" else None,
 
                 AddFlag("-fsanitize=dataflow") if sanitizer == "DataFlow" else None,

>From a3c2de6e53bab2f4dcde6a69ed4bb8f1de8ebcb5 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 13:16:16 -0400
Subject: [PATCH 07/19] try more workarounds

---
 .github/workflows/libcxx-build-and-test.yaml                 | 2 +-
 libcxx/test/std/thread/futures/futures.async/async.pass.cpp  | 1 -
 .../thread/futures/futures.async/wait_on_destruct.pass.cpp   | 5 +++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index 7318bef43e9f0..da4295fe94f97 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -42,7 +42,7 @@ jobs:
     steps:
       - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
       - name: generic-tsan
-        run: sudo sysctl vm.mmap_rnd_bits=32; libcxx/utils/ci/run-buildbot generic-tsan
+        run: sudo sysctl vm.mmap_rnd_bits=30 && ulimit -s 16000000; libcxx/utils/ci/run-buildbot generic-tsan
         env:
           CC: clang-21
           CXX: clang++-21
diff --git a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
index 109372b50a311..2bbfaa37915a8 100644
--- a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
@@ -9,7 +9,6 @@
 // UNSUPPORTED: no-threads
 // UNSUPPORTED: c++03
 
-// ALLOW_RETRIES: 3
 
 // <future>
 
diff --git a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
index 8260ec3dfcaf4..2b98d265b55fc 100644
--- a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
@@ -22,17 +22,18 @@
 #include <mutex>
 
 std::mutex mux;
+std::atomic<bool> in_async = false;
 
 int main(int, char**) {
   using namespace std::chrono_literals;
   std::unique_lock lock(mux);
-  std::atomic<bool> in_async = false;
+
   auto v                     = std::async(std::launch::async, [&in_async, value = 1]() mutable {
     in_async = true;
     in_async.notify_all();
     std::scoped_lock thread_lock(mux);
     value = 4;
-    (void)value;
+    return value;
   });
   in_async.wait(true);
   lock.unlock();

>From b18aea3e3f1625b2a84fc75e34cba74d62ab3614 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 13:24:03 -0400
Subject: [PATCH 08/19] try different flags

---
 .github/workflows/libcxx-build-and-test.yaml              | 2 +-
 .../futures/futures.async/wait_on_destruct.pass.cpp       | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index da4295fe94f97..95b91d9b2f9a0 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -42,7 +42,7 @@ jobs:
     steps:
       - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
       - name: generic-tsan
-        run: sudo sysctl vm.mmap_rnd_bits=30 && ulimit -s 16000000; libcxx/utils/ci/run-buildbot generic-tsan
+        run: sudo sysctl vm.mmap_rnd_bits=32 && ulimit -s 16000000; libcxx/utils/ci/run-buildbot generic-tsan
         env:
           CC: clang-21
           CXX: clang++-21
diff --git a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
index 2b98d265b55fc..9b3377ec06794 100644
--- a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
@@ -20,20 +20,22 @@
 #include <atomic>
 #include <future>
 #include <mutex>
+#include <thread>
+#include <chrono>
 
 std::mutex mux;
-std::atomic<bool> in_async = false;
 
 int main(int, char**) {
   using namespace std::chrono_literals;
   std::unique_lock lock(mux);
-
+  std::atomic<bool> in_async = false;
   auto v                     = std::async(std::launch::async, [&in_async, value = 1]() mutable {
     in_async = true;
     in_async.notify_all();
+    std::this_thread::sleep_for(std::chrono::seconds(1));
     std::scoped_lock thread_lock(mux);
     value = 4;
-    return value;
+    (void)value;
   });
   in_async.wait(true);
   lock.unlock();

>From 5a9d4922cfdb15c141dbd88551e85e547d964fb6 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 13:42:01 -0400
Subject: [PATCH 09/19] try again

---
 .github/workflows/libcxx-build-and-test.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index 95b91d9b2f9a0..da4295fe94f97 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -42,7 +42,7 @@ jobs:
     steps:
       - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
       - name: generic-tsan
-        run: sudo sysctl vm.mmap_rnd_bits=32 && ulimit -s 16000000; libcxx/utils/ci/run-buildbot generic-tsan
+        run: sudo sysctl vm.mmap_rnd_bits=30 && ulimit -s 16000000; libcxx/utils/ci/run-buildbot generic-tsan
         env:
           CC: clang-21
           CXX: clang++-21

>From 1b44f66e8f37193e6fe2b609e4c4aadeeb9bc9d8 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 15:04:17 -0400
Subject: [PATCH 10/19] try another thing

---
 .github/workflows/libcxx-build-and-test.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index da4295fe94f97..e864d55a55869 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -42,7 +42,7 @@ jobs:
     steps:
       - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
       - name: generic-tsan
-        run: sudo sysctl vm.mmap_rnd_bits=30 && ulimit -s 16000000; libcxx/utils/ci/run-buildbot generic-tsan
+        run: ulimit -s unlimited; libcxx/utils/ci/run-buildbot generic-tsan
         env:
           CC: clang-21
           CXX: clang++-21

>From 85e4c02120c7c7f961658cc7eb3f4cec4b5279e4 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 15:05:28 -0400
Subject: [PATCH 11/19] fix whitespace

---
 libcxx/test/std/thread/futures/futures.async/async.pass.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
index 2bbfaa37915a8..b568c5e7fcfe3 100644
--- a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
@@ -9,7 +9,6 @@
 // UNSUPPORTED: no-threads
 // UNSUPPORTED: c++03
 
-
 // <future>
 
 // template <class F, class... Args>

>From 48341114fa8504dcbfd803ea9531de0b619444f5 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 15:12:47 -0400
Subject: [PATCH 12/19] try again; this time with the config we think works

---
 .github/workflows/libcxx-build-and-test.yaml | 2 +-
 libcxx/cmake/caches/Generic-tsan.cmake       | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index e864d55a55869..f13aac945a241 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -42,7 +42,7 @@ jobs:
     steps:
       - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
       - name: generic-tsan
-        run: ulimit -s unlimited; libcxx/utils/ci/run-buildbot generic-tsan
+        run: sudo sysctl vm.mmap_rnd_bits=30; libcxx/utils/ci/run-buildbot generic-tsan
         env:
           CC: clang-21
           CXX: clang++-21
diff --git a/libcxx/cmake/caches/Generic-tsan.cmake b/libcxx/cmake/caches/Generic-tsan.cmake
index de4a76d7842ea..18d5fd9a0e896 100644
--- a/libcxx/cmake/caches/Generic-tsan.cmake
+++ b/libcxx/cmake/caches/Generic-tsan.cmake
@@ -1,3 +1,2 @@
 set(LLVM_USE_SANITIZER "Thread" CACHE STRING "")
-set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "") # TSAN is compiled against the system unwinder, which leads to false positives
-set(LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "FIXME: This is a temporary workaround to get tsan running again")
\ No newline at end of file
+set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "") # TSAN is compiled against the system unwinder, which leads to false positives
\ No newline at end of file

>From 622638dfb94c800c43c3b7f4fa61e5744448b72b Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 15:48:48 -0400
Subject: [PATCH 13/19] rewrite failing test

---
 .../futures.async/wait_on_destruct.pass.cpp    | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
index 9b3377ec06794..a354a9c77fefe 100644
--- a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
@@ -21,6 +21,7 @@
 #include <future>
 #include <mutex>
 #include <thread>
+#include <condition>
 #include <chrono>
 
 std::mutex mux;
@@ -28,17 +29,18 @@ std::mutex mux;
 int main(int, char**) {
   using namespace std::chrono_literals;
   std::unique_lock lock(mux);
-  std::atomic<bool> in_async = false;
-  auto v                     = std::async(std::launch::async, [&in_async, value = 1]() mutable {
-    in_async = true;
-    in_async.notify_all();
-    std::this_thread::sleep_for(std::chrono::seconds(1));
-    std::scoped_lock thread_lock(mux);
+  std::condition_variable cond;
+  auto v                     = std::async(std::launch::async, [&cond, value = 1]() mutable {
+
+    std::unique_lock thread_lock(mux);
+    cond.notify_all();
+    thread_lock.unlock();
+
     value = 4;
     (void)value;
   });
-  in_async.wait(true);
-  lock.unlock();
+  cond.wait(mux);
+
 
   return 0;
 }

>From 9f57fbdf8a52fd6fffe218a95ee99b00fe32005a Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 15:53:25 -0400
Subject: [PATCH 14/19] redisable the sanitizers for reasons I don't understand

---
 libcxx/cmake/caches/Generic-tsan.cmake | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libcxx/cmake/caches/Generic-tsan.cmake b/libcxx/cmake/caches/Generic-tsan.cmake
index 18d5fd9a0e896..de4a76d7842ea 100644
--- a/libcxx/cmake/caches/Generic-tsan.cmake
+++ b/libcxx/cmake/caches/Generic-tsan.cmake
@@ -1,2 +1,3 @@
 set(LLVM_USE_SANITIZER "Thread" CACHE STRING "")
-set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "") # TSAN is compiled against the system unwinder, which leads to false positives
\ No newline at end of file
+set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "") # TSAN is compiled against the system unwinder, which leads to false positives
+set(LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "FIXME: This is a temporary workaround to get tsan running again")
\ No newline at end of file

>From 8fe1d19a6a4f2437ec974b59cc600dcc7c1d8154 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 15:58:19 -0400
Subject: [PATCH 15/19] add correct header

---
 .../thread/futures/futures.async/wait_on_destruct.pass.cpp    | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
index a354a9c77fefe..383fc39f1de52 100644
--- a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
@@ -20,9 +20,7 @@
 #include <atomic>
 #include <future>
 #include <mutex>
-#include <thread>
-#include <condition>
-#include <chrono>
+#include <condition_variable>
 
 std::mutex mux;
 

>From b516cd8abeb37898d53a8efa816fec15ad58d1ad Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sat, 28 Jun 2025 16:02:52 -0400
Subject: [PATCH 16/19] last one, promise

---
 .../std/thread/futures/futures.async/wait_on_destruct.pass.cpp  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
index 383fc39f1de52..70903f3ebe440 100644
--- a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
@@ -37,7 +37,7 @@ int main(int, char**) {
     value = 4;
     (void)value;
   });
-  cond.wait(mux);
+  cond.wait(lock);
 
 
   return 0;

>From f789c41d3c267c02f5629e69aa8358c398612f35 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sun, 29 Jun 2025 10:48:31 -0400
Subject: [PATCH 17/19] remove other changes

---
 .../thread/futures/futures.async/async.pass.cpp |  2 ++
 .../futures.async/wait_on_destruct.pass.cpp     | 17 +++++++----------
 libcxx/utils/libcxx/test/params.py              |  2 +-
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
index b568c5e7fcfe3..109372b50a311 100644
--- a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp
@@ -9,6 +9,8 @@
 // UNSUPPORTED: no-threads
 // UNSUPPORTED: c++03
 
+// ALLOW_RETRIES: 3
+
 // <future>
 
 // template <class F, class... Args>
diff --git a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
index 70903f3ebe440..8260ec3dfcaf4 100644
--- a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
@@ -20,25 +20,22 @@
 #include <atomic>
 #include <future>
 #include <mutex>
-#include <condition_variable>
 
 std::mutex mux;
 
 int main(int, char**) {
   using namespace std::chrono_literals;
   std::unique_lock lock(mux);
-  std::condition_variable cond;
-  auto v                     = std::async(std::launch::async, [&cond, value = 1]() mutable {
-
-    std::unique_lock thread_lock(mux);
-    cond.notify_all();
-    thread_lock.unlock();
-
+  std::atomic<bool> in_async = false;
+  auto v                     = std::async(std::launch::async, [&in_async, value = 1]() mutable {
+    in_async = true;
+    in_async.notify_all();
+    std::scoped_lock thread_lock(mux);
     value = 4;
     (void)value;
   });
-  cond.wait(lock);
-
+  in_async.wait(true);
+  lock.unlock();
 
   return 0;
 }
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index e187ffa44a9e5..fc34009d0a551 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -330,7 +330,7 @@ def getSuitableClangTidy(cfg):
                 AddFeature("msan")                         if sanitizer in ["Memory", "MemoryWithOrigins"] else None,
                 AddFlag("-fsanitize-memory-track-origins") if sanitizer == "MemoryWithOrigins" else None,
 
-                AddFlag("-fsanitize=thread -fno-sanitize-recover=all  -O1") if sanitizer == "Thread" else None,
+                AddFlag("-fsanitize=thread") if sanitizer == "Thread" else None,
                 AddFeature("tsan")           if sanitizer == "Thread" else None,
 
                 AddFlag("-fsanitize=dataflow") if sanitizer == "DataFlow" else None,

>From b348b2bd28ea574c7a7894b871f9a722bb9bdd2b Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sun, 29 Jun 2025 11:11:17 -0400
Subject: [PATCH 18/19] try reducing aslr even further

---
 .github/workflows/libcxx-build-and-test.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index f13aac945a241..4d89cc163ca17 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -42,7 +42,7 @@ jobs:
     steps:
       - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
       - name: generic-tsan
-        run: sudo sysctl vm.mmap_rnd_bits=30; libcxx/utils/ci/run-buildbot generic-tsan
+        run: sudo sysctl vm.mmap_rnd_bits=28; libcxx/utils/ci/run-buildbot generic-tsan
         env:
           CC: clang-21
           CXX: clang++-21

>From 686c0f4855f07e5f196fe84d42fc8e0c33e90524 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sun, 29 Jun 2025 11:34:37 -0400
Subject: [PATCH 19/19] try reducing aslr even further

---
 .github/workflows/libcxx-build-and-test.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index 4d89cc163ca17..6c549518a79e4 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -42,7 +42,7 @@ jobs:
     steps:
       - uses: actions/checkout at 11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
       - name: generic-tsan
-        run: sudo sysctl vm.mmap_rnd_bits=28; libcxx/utils/ci/run-buildbot generic-tsan
+        run: sudo sysctl vm.mmap_rnd_bits=28; sudo sysctl vm.randomize_va_space=0; libcxx/utils/ci/run-buildbot generic-tsan
         env:
           CC: clang-21
           CXX: clang++-21



More information about the llvm-commits mailing list