diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index e0d460ce..4c3150d1 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1,3 +1,4 @@ + name: Linux on: workflow_dispatch: @@ -47,10 +48,10 @@ jobs: - name: Install LLVM and Clang if: matrix.sys.compiler == 'clang' - uses: egor-tensin/setup-clang@v1 + uses: KyleMayes/install-llvm-action@v2 with: version: ${{matrix.sys.version}} - platform: x64 + arch: x64 - name: Install the specified standard library for clang if: matrix.sys.compiler == 'clang' @@ -98,7 +99,8 @@ jobs: -DBUILD_TESTS=ON \ -DBUILD_EXAMPLES=ON \ -DCMAKE_C_COMPILER_LAUNCHER=sccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ + -DUSE_SANITIZER="address;undefined;leak" - name: Build library working-directory: build @@ -112,13 +114,30 @@ jobs: working-directory: build run: cmake --build . --config ${{matrix.config.name}} --target test_sparrow_lib --parallel 8 + - name: fine-tune asan options + # in asan we get an error from std::regex. ignore it. + run: | + echo "ASAN_OPTIONS=log_path=asan_log_:alloc_dealloc_mismatch=0:halt_on_error=0:handle_abort=0:exitcode=0" >> $GITHUB_ENV + echo "LEAK_OPTIONS=log_path=leak_log_" >> $GITHUB_ENV + - name: Run sccache stat for check shell: bash run: ${SCCACHE_PATH} --show-stats - name: Run tests working-directory: build - run: cmake --build . --config ${{matrix.config.name}} --target run_tests_with_junit_report + run: | + export ASAN_OPTIONS=log_path=asan_log_:alloc_dealloc_mismatch=0:halt_on_error=0:handle_abort=0:exitcode=0 + export LEAK_OPTIONS=log_path=leak_log_ + cmake --build . --config ${{matrix.config.name}} --target run_tests_with_junit_report + # env: + # # log_path is set to the path where ASAN will write the error report (seems ineffective) + # # alloc_dealloc_mismatch is set to 0 to deactivate unwanted ASAN warnings. + # # halt_on_error is set to 0 to avoid crashing the program after printing the first error report. + # # handle_abort is set to 0 to deactivate calls are handled as crashes by ASAN. + # # exitcode is set to 0 to avoid reporting the build as failed if ASAN detects an error. + # ASAN_OPTIONS: log_path=asan_log_:alloc_dealloc_mismatch=0:halt_on_error=0:handle_abort=0:exitcode=0 + # LEAK_OPTIONS: log_path=leak_log_ - name: Upload test results uses: actions/upload-artifact@v4 @@ -127,6 +146,23 @@ jobs: name: test_sparrow_lib_report_Linux_${{ matrix.sys.compiler }}_${{ matrix.sys.version }}_${{ matrix.sys.stdlib }}_${{ matrix.config.name }}_date-polyfill_${{ matrix.sys.date-polyfill}} path: '**/test_sparrow_lib_report.xml' + + - name: Upload ASAN log + if: always() + uses: actions/upload-artifact@v4 + with: + name: asan-log-${{ matrix.sys.compiler }}-${{ matrix.sys.version }}-${{ matrix.config.name }}-${{ matrix.sys.date-polyfill }} + path: '**/asan_log_*' + + - name: Upload LEAK log + if: always() + uses: actions/upload-artifact@v4 + with: + name: leak-log-${{ matrix.sys.compiler }}-${{ matrix.sys.version }}-${{ matrix.config.name }}-${{ matrix.sys.date-polyfill }} + path: '**/leak_log_*' + + - name: Run all examples working-directory: build run: cmake --build . --config ${{matrix.config.name}} --target run_examples + diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 5a5ab9f0..f9a078cd 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -180,7 +180,10 @@ jobs: $SPARROW_ADDITIONAL_OPTIONS \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL + -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL \ + ${{env.CMAKE_SANITIZER}} + env: + CMAKE_SANITIZER: ${{ (matrix.config.name == 'Debug' && matrix.sys.compiler == 'msvc') && '-DUSE_SANITIZER=address' || '' }} - name: Build library working-directory: build diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c6cecb39..e07c74d1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -199,7 +199,10 @@ target_link_options(${test_target} PRIVATE $<$:${SANITIZER_LINK_OPTIONS}>) # We do not use non-standard C++ -set_target_properties(${test_target} PROPERTIES CMAKE_CXX_EXTENSIONS OFF) +set_target_properties(${test_target} + PROPERTIES + CMAKE_CXX_EXTENSIONS OFF + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") target_compile_features(${test_target} PRIVATE cxx_std_20) add_custom_target(run_tests