diff --git a/.github/workflows/profiling-native.yml b/.github/workflows/profiling-native.yml new file mode 100644 index 00000000000..98722552dbd --- /dev/null +++ b/.github/workflows/profiling-native.yml @@ -0,0 +1,48 @@ +name: Profiling Native Tests with Sanitizers + +on: + push: + branches: + - main + - "mq-working-branch**" + pull_request: + paths: + - ddtrace/internal/datadog/profiling/** + - ddtrace/profiling/** + workflow_dispatch: {} + +jobs: + test: + runs-on: ${{ matrix.os }} + timeout-minutes: 5 + strategy: + fail-fast: false + matrix: + os: [ubuntu-24.04] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + sanitizer: ["safety", "thread"] + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + fetch-depth: 1 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install llvm 19 + run: | + # Ubuntu-24.04 GH actions image has llvm-18, but we use 19 as it's + # the latest one available. + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 19 + + - name: Run tests with sanitizers + run: | + # DEV: We currently have tests in dd_wrapper and stack_v2, setting + # stack_v2 here will also run tests in dd_wrapper. Revisit this when + # that changes. + ./ddtrace/internal/datadog/profiling/build_standalone.sh --${{matrix.sanitizer}} RelWithDebInfo stack_v2_test diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/CMakeLists.txt b/ddtrace/internal/datadog/profiling/dd_wrapper/test/CMakeLists.txt index 6a1e7f406f6..0be6098cd2a 100644 --- a/ddtrace/internal/datadog/profiling/dd_wrapper/test/CMakeLists.txt +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/test/CMakeLists.txt @@ -21,7 +21,12 @@ function(dd_wrapper_add_test name) target_link_libraries(${name} PRIVATE gmock gtest_main dd_wrapper nlohmann_json::nlohmann_json) add_ddup_config(${name}) - gtest_discover_tests(${name}) + gtest_discover_tests(${name} + PROPERTIES + # We start new threads after fork(), and we want to continue + # running the tests after that instead of dying. + ENVIRONMENT "TSAN_OPTIONS=die_after_fork=0:suppressions=${CMAKE_CURRENT_SOURCE_DIR}/TSan.supp" + ) set_target_properties(${name} PROPERTIES INSTALL_RPATH "$ORIGIN/..") diff --git a/ddtrace/internal/datadog/profiling/dd_wrapper/test/TSan.supp b/ddtrace/internal/datadog/profiling/dd_wrapper/test/TSan.supp new file mode 100644 index 00000000000..bc9e9d23668 --- /dev/null +++ b/ddtrace/internal/datadog/profiling/dd_wrapper/test/TSan.supp @@ -0,0 +1,4 @@ +# libdd is not compiled with sanitizers so probably that's why we get these +# data races from ddog_ArrayQueue and Datadog::Sample operations +race:ddog_ArrayQueue +race:Datadog::Sample:: diff --git a/ddtrace/internal/datadog/profiling/stack_v2/CMakeLists.txt b/ddtrace/internal/datadog/profiling/stack_v2/CMakeLists.txt index 9fc78ee8046..50c8d056c79 100644 --- a/ddtrace/internal/datadog/profiling/stack_v2/CMakeLists.txt +++ b/ddtrace/internal/datadog/profiling/stack_v2/CMakeLists.txt @@ -37,7 +37,7 @@ endif() # Add echion set(ECHION_COMMIT - "9d5bcc5867d7aefff73c837adcba4ef46eecebc6" + "ed744987f224fae3f93c842b2b5ffb083984ff8b" CACHE STRING "Commit hash of echion to use") FetchContent_Declare( echion