|
| 1 | +name: Thread Sanitizer |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: tsan-${{ github.workflow }}-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + tsan: |
| 21 | + name: TSan |
| 22 | + runs-on: ubuntu-latest |
| 23 | + container: |
| 24 | + image: helics/buildenv:sanitizers-22 |
| 25 | + |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v6 |
| 28 | + with: |
| 29 | + submodules: recursive |
| 30 | + |
| 31 | + - name: Mark workspace as safe for git |
| 32 | + run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" |
| 33 | + |
| 34 | + - name: Install SuiteSparse build dependencies |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + apt-get update |
| 38 | + apt-get install -y libblas-dev liblapack-dev libunwind-dev |
| 39 | +
|
| 40 | + - name: Prepare TSan runtime libraries |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + libunwind_path="$(ldconfig -p | awk '/libunwind\.so/ { print $NF; exit }')" |
| 44 | + if [ -z "${libunwind_path}" ]; then |
| 45 | + echo "Unable to locate a libunwind shared library" |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | + if [ ! -e /root/develop/libcxx_tsan/lib/libunwind.so.1 ]; then |
| 49 | + ln -s "${libunwind_path}" /root/develop/libcxx_tsan/lib/libunwind.so.1 |
| 50 | + fi |
| 51 | +
|
| 52 | + - name: Configure |
| 53 | + shell: bash |
| 54 | + run: > |
| 55 | + cmake -S . -B build |
| 56 | + -DCMAKE_C_COMPILER=clang |
| 57 | + -DCMAKE_CXX_COMPILER=clang++ |
| 58 | + -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer -g -O1" |
| 59 | + -DCMAKE_CXX_FLAGS="-fsanitize=thread -nostdinc++ -nostdlib++ -L/root/develop/libcxx_tsan/lib -lc++ -lc++abi -I/root/develop/libcxx_tsan/include -I/root/develop/libcxx_tsan/include/c++/v1 -Wno-unused-command-line-argument -Wno-reserved-identifier -Wno-reserved-macro-identifier -fno-omit-frame-pointer -g -O1 -Wl,-rpath=/root/develop/libcxx_tsan/lib" |
| 60 | + -DBUILD_TESTING=ON |
| 61 | + -DGRIDDYN_BUILD_TESTS=ON |
| 62 | + -DGRIDDYN_SUITESPARSE_FORCE_SUBPROJECT=ON |
| 63 | + -DGRIDDYN_ENABLE_FMI=OFF |
| 64 | + -DGRIDDYN_ENABLE_HELICS_EXECUTABLE=OFF |
| 65 | +
|
| 66 | + - name: Build |
| 67 | + shell: bash |
| 68 | + run: cmake --build build --parallel 4 |
| 69 | + |
| 70 | + - name: Run TSan tests |
| 71 | + shell: bash |
| 72 | + run: > |
| 73 | + LD_LIBRARY_PATH="/root/develop/libcxx_tsan/lib:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}" |
| 74 | + TSAN_OPTIONS="second_deadlock_stack=1 suppressions=${GITHUB_WORKSPACE}/config/tsan_suppression.txt history_size=4" |
| 75 | + ctest --test-dir build --output-on-failure -L Continuous |
0 commit comments