Debian Codegraph @

.github/workflows/tsan.yml

raw
1 # Build the compiler and run the testsuite with ThreadSanitizer, if PR is
2 # labelled with run-thread-sanitizer
3 name: Run testsuite with ThreadSanitizer
4 on:
5 pull_request:
6 types: [opened, synchronize, reopened, labeled, unlabeled]
7
8 # Restrict the GITHUB_TOKEN
9 permissions: {}
10
11 # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
12 # Concurrent workflows are grouped by the PR or branch that triggered them
13 # (github.ref) and the name of the workflow (github.workflow). The
14 # 'cancel-in-progress' option then make sure that only one workflow is running
15 # at a time. This doesn't prevent new jobs from running, rather it cancels
16 # already running jobs before scheduling new jobs.
17 concurrency:
18 group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'pull_request' || github.sha }}
19 cancel-in-progress: true
20
21 jobs:
22 # This job will do the initial build of the compiler (on linux).
23 # We then upload the compiler tree as a build artifact to enable re-use in
24 # subsequent jobs.
25 build:
26 if: contains(github.event.pull_request.labels.*.name, 'run-thread-sanitizer')
27 runs-on: 'ubuntu-latest'
28 outputs:
29 manual_changed: ${{ steps.manual.outputs.manual_changed }}
30 steps:
31 - name: Checkout
32 uses: actions/checkout@v5
33 with:
34 persist-credentials: false
35 - name: Install libunwind
36 run: |
37 sudo apt-get update -y
38 sudo apt-get install -y libunwind-dev
39 # This temporary workaround reduces the number of random bits for the base
40 # address of vma regions for mmap allocation, to avoid the
41 # "FATAL: ThreadSanitizer: unexpected memory mapping" TSan error.
42 # See: https://github.com/google/sanitizers/issues/1716
43 - name: Tune vm.mmap_rnd_bits value for TSan
44 run: sudo sysctl vm.mmap_rnd_bits=28
45 - name: Configure tree
46 run: |
47 MAKE_ARG=-j CONFIG_ARG='--enable-cmm-invariants --enable-dependency-generation --enable-native-toplevel --enable-tsan --enable-ocamltest CPPFLAGS=-DTSAN_INSTRUMENT_ALL' OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh configure
48 - name: Build
49 run: |
50 MAKE_ARG=-j bash -xe tools/ci/actions/runner.sh build
51 - name: Prepare Artifact
52 run: tar --zstd -cf /tmp/sources.tar.zstd .
53 - name: Upload Artifact
54 uses: actions/upload-artifact@v4
55 with:
56 name: compiler
57 path: /tmp/sources.tar.zstd
58 retention-days: 1
59
60 # Testsuite run jobs:
61 # normal: Run the full testsuite
62 # debug: Run the full testsuite with the debug runtime and minor heap
63 # verification.
64 normal:
65 if: contains(github.event.pull_request.labels.*.name, 'run-thread-sanitizer')
66 name: ${{ matrix.name }}
67 needs: build
68 runs-on: ubuntu-latest
69 strategy:
70 matrix:
71 include:
72 - id: normal
73 name: normal
74 dependencies: libunwind-dev
75 - id: debug
76 name: debug runtime
77 dependencies: libunwind-dev
78 steps:
79 - name: Download Artifact
80 uses: actions/download-artifact@v4
81 with:
82 name: compiler
83 - name: Unpack Artifact
84 run: |
85 tar --zstd -xf sources.tar.zstd
86 rm -f sources.tar.zstd
87 - name: Packages
88 if: matrix.dependencies != ''
89 run: |
90 sudo apt-get update -y
91 sudo apt-get install -y ${{ matrix.dependencies }}
92 - name: Run the testsuite
93 if: matrix.id == 'normal'
94 # Run testsuite with 30-minute timeout per test
95 run: |
96 TIMEOUT=1800 TSAN_OPTIONS=history_size=6 OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh test_sequential
97 - name: Run the testsuite (debug runtime)
98 if: matrix.id == 'debug'
99 env:
100 OCAMLRUNPARAM: v=0,V=1
101 USE_RUNTIME: d
102 run: |
103 bash -cxe "TSAN_OPTIONS=history_size=6 SHOW_TIMINGS=1 tools/ci/actions/runner.sh test_sequential"