diff --git a/.github/workflows/tsan.yml b/.github/workflows/tsan.yml new file mode 100644 index 00000000..f6957d2b --- /dev/null +++ b/.github/workflows/tsan.yml @@ -0,0 +1,31 @@ +name: tsan + +on: + push: + branches: + - master + paths: + - '**' + - '!.gitignore' + - '!LICENSE' + - '!README.md' + - '!docs/**' + - '!examples/**' + - '.github/workflows/tsan.yml' + - '.github/workflows/valgrind.yml' + workflow_dispatch: + +jobs: + linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: build + run: | + cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONFIG_TSAN=ON + cmake --build build -j`nproc` + - name: test + run: | + ./build/run-test262 -m -c test262.conf -c test262-fast.conf -a diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 8f26d6aa..5ea446f9 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -11,6 +11,7 @@ on: - '!README.md' - '!docs/**' - '!examples/**' + - '.github/workflows/tsan.yml' - '.github/workflows/valgrind.yml' workflow_dispatch: diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bd0c3ae..aabaf5a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,7 @@ xoption(BUILD_CLI_WITH_MIMALLOC "Build the qjs executable with mimalloc" OFF) xoption(BUILD_CLI_WITH_STATIC_MIMALLOC "Build the qjs executable with mimalloc (statically linked)" OFF) xoption(CONFIG_ASAN "Enable AddressSanitizer (ASan)" OFF) xoption(CONFIG_MSAN "Enable MemorySanitizer (MSan)" OFF) +xoption(CONFIG_TSAN "Enable ThreadSanitizer (TSan)" OFF) xoption(CONFIG_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan)" OFF) if(CONFIG_ASAN) @@ -144,6 +145,18 @@ add_link_options( -fno-sanitize-recover=all -fno-omit-frame-pointer ) +elseif(CONFIG_TSAN) +message(STATUS "Building with TSan") +add_compile_options( + -fsanitize=thread + -fno-sanitize-recover=all + -fno-omit-frame-pointer +) +add_link_options( + -fsanitize=thread + -fno-sanitize-recover=all + -fno-omit-frame-pointer +) elseif(CONFIG_UBSAN) message(STATUS "Building with UBSan") add_compile_definitions(