From 562afa1e6991103dd0ed80b3fc32a311c71c1de1 Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Fri, 24 Oct 2025 15:57:51 +0200 Subject: [PATCH 1/4] Make ASAN happy even more --- gradle/patching.gradle | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/gradle/patching.gradle b/gradle/patching.gradle index 2c72c1d9f..f9ea6eaf5 100644 --- a/gradle/patching.gradle +++ b/gradle/patching.gradle @@ -220,8 +220,16 @@ ext.upstreamPatches = [ // Symbol implementation patches for DataDog-specific API extensions "symbols_linux.cpp": [ - validations: [[contains: "#ifdef __linux__"], [contains: "_parsed_inodes"]], + validations: [[contains: "#ifdef __linux__"], [contains: "_parsed_inodes"], [contains: "loadSymbolTable"]], operations: [ + [ + type: "expression_replace", + name: "Fix pointer overflow in loadSymbolTable", + description: "Replace unsafe pointer arithmetic with overflow-safe version to prevent ASAN failures while preserving original semantics", + find: "const char\\* addr = base != NULL \\? base \\+ sym->st_value : \\(const char\\*\\)sym->st_value;", + replace: "// Use safe pointer arithmetic to avoid ASAN overflow while preserving original NULL base semantics\n const char* addr = base != NULL ? (const char*)((uintptr_t)base + (uintptr_t)sym->st_value) : (const char*)sym->st_value;", + idempotent_check: "// Use safe pointer arithmetic to avoid ASAN overflow while preserving original NULL base semantics" + ], [ type: "method_implementation", name: "Add clearParsingCaches method implementation", @@ -233,6 +241,21 @@ ext.upstreamPatches = [ ] ], + // Symbol implementation patches for macOS (DataDog-specific API extensions and ASan compatibility) + "symbols_macos.cpp": [ + validations: [[contains: "#ifdef __APPLE__"], [contains: "loadSymbols"], [contains: "n_value"]], + operations: [ + [ + type: "expression_replace", + name: "Fix pointer overflow in loadSymbols for macOS", + description: "Replace unsafe pointer arithmetic with overflow-safe version to prevent ASAN failures on macOS", + find: "const char\\* addr = _vmaddr_slide \\+ sym->n_value;", + replace: "// Use safer arithmetic to avoid ASAN overflow while preserving all symbols\n const char* addr = (const char*)((uintptr_t)_vmaddr_slide + (uintptr_t)sym->n_value);", + idempotent_check: "// Use safer arithmetic to avoid ASAN overflow while preserving all symbols" + ] + ] + ], + // Stack frame header patches for DataDog-specific API extensions "stackFrame.h": [ validations: [ From 139e82983ee1107b8b35600591ee82cb98af705c Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Fri, 24 Oct 2025 16:32:32 +0200 Subject: [PATCH 2/4] Typo fix --- .github/scripts/prepare_reports.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/prepare_reports.sh b/.github/scripts/prepare_reports.sh index 5ee67deb4..92f606413 100755 --- a/.github/scripts/prepare_reports.sh +++ b/.github/scripts/prepare_reports.sh @@ -1,4 +1,4 @@ - #!/usr/bin/env bash +#!/usr/bin/env bash set -e mkdir -p test-reports From 66a98a99dfba81864b398047bfcb6e7d1e55595d Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Fri, 24 Oct 2025 16:56:02 +0200 Subject: [PATCH 3/4] Unify enablement in test jobs --- .github/workflows/test_workflow.yml | 82 +++++++++++++++++++---------- 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 9bd0c1bf8..16adeb0a1 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -103,39 +103,39 @@ jobs: exit 1 fi - name: Generate Unwinding Report - if: success() && matrix.config == 'debug' + if: steps.set_enabled.outputs.enabled == 'true' && success() && matrix.config == 'debug' run: | ./gradlew -PCI :ddprof-test:unwindingReport --no-daemon - name: Add Unwinding Report to Job Summary - if: success() && matrix.config == 'debug' && hashFiles('ddprof-test/build/reports/unwinding-summary.md') != '' + if: steps.set_enabled.outputs.enabled == 'true' && success() && matrix.config == 'debug' && hashFiles('ddprof-test/build/reports/unwinding-summary.md') != '' run: | echo "## 🔧 Unwinding Quality Report - ${{ matrix.java_version }} (amd64)" >> $GITHUB_STEP_SUMMARY cat ddprof-test/build/reports/unwinding-summary.md >> $GITHUB_STEP_SUMMARY - name: Upload build artifacts uses: actions/upload-artifact@v4 - if: success() + if: steps.set_enabled.outputs.enabled == 'true' && success() with: name: (build) test-linux-glibc-amd64 (${{ matrix.java_version }}, ${{ matrix.config }}) path: build/ - name: Upload failures uses: actions/upload-artifact@v4 - if: failure() + if: steps.set_enabled.outputs.enabled == 'true' && failure() with: name: failures-glibc-${{ matrix.java_version }}-${{ matrix.config }}-amd64 path: failures_glibc-${{ matrix.java_version }}-${{ matrix.config }}-amd64.txt - name: Prepare reports - if: always() + if: steps.set_enabled.outputs.enabled == 'true' && always() run: | .github/scripts/prepare_reports.sh - name: Upload unwinding reports uses: actions/upload-artifact@v4 - if: success() && matrix.config == 'debug' + if: steps.set_enabled.outputs.enabled == 'true' && success() && matrix.config == 'debug' with: name: (unwinding-reports) unwinding-linux-glibc-amd64 (${{ matrix.java_version }}, ${{ matrix.config }}) path: unwinding-reports - name: Upload test reports uses: actions/upload-artifact@v4 - if: failure() + if: steps.set_enabled.outputs.enabled == 'true' && failure() with: name: (test-reports) test-linux-glibc-amd64 (${{ matrix.java_version }}, ${{ matrix.config }}) path: test-reports @@ -153,6 +153,15 @@ jobs: options: --cpus 4 --workdir /github/workspace -v /home/runner/work/_temp:/home/runner/work/_temp timeout-minutes: 180 steps: + - name: Set enabled flag + id: set_enabled + run: | + echo "enabled=true" >> $GITHUB_OUTPUT + if [[ "${{ matrix.java_version }}" =~ -zing ]]; then + if [[ "${{ matrix.config }}" != "release" ]] && [[ "${{ matrix.config }}" != "debug" ]]; then + echo "enabled=false" >> $GITHUB_OUTPUT + fi + fi - name: Setup OS run: | apk update && apk add curl moreutils wget hexdump linux-headers bash make g++ clang git cppcheck jq cmake gtest-dev gmock tar binutils >/dev/null @@ -160,6 +169,7 @@ jobs: apk add musl-dbg - uses: actions/checkout@v3 - name: Cache Gradle Wrapper Binaries + if: steps.set_enabled.outputs.enabled == 'true' uses: actions/cache@v4 with: path: ~/.gradle/wrapper/dists @@ -167,6 +177,7 @@ jobs: restore-keys: | gradle-wrapper-${{ runner.os }}- - name: Cache Gradle User Home + if: steps.set_enabled.outputs.enabled == 'true' uses: actions/cache@v4 with: path: ~/.gradle/caches @@ -184,13 +195,16 @@ jobs: async-profiler-${{ runner.os }}- - name: Setup cached JDK id: cache-jdk + if: steps.set_enabled.outputs.enabled == 'true' uses: ./.github/actions/setup_cached_java with: version: ${{ matrix.java_version }} arch: 'amd64-musl' - name: Extract Versions + if: steps.set_enabled.outputs.enabled == 'true' uses: ./.github/actions/extract_versions - name: Test + if: steps.set_enabled.outputs.enabled == 'true' run: | set +e @@ -226,39 +240,39 @@ jobs: exit 1 fi - name: Generate Unwinding Report - if: success() && matrix.config == 'debug' + if: steps.set_enabled.outputs.enabled == 'true' && success() && matrix.config == 'debug' run: | ./gradlew -PCI :ddprof-test:unwindingReport --no-daemon - name: Add Unwinding Report to Job Summary - if: success() && matrix.config == 'debug' && hashFiles('ddprof-test/build/reports/unwinding-summary.md') != '' + if: steps.set_enabled.outputs.enabled == 'true' && success() && matrix.config == 'debug' && hashFiles('ddprof-test/build/reports/unwinding-summary.md') != '' run: | echo "## 🔧 Unwinding Quality Report - ${{ matrix.java_version }} (amd64-musl)" >> $GITHUB_STEP_SUMMARY cat ddprof-test/build/reports/unwinding-summary.md >> $GITHUB_STEP_SUMMARY - name: Upload build artifacts uses: actions/upload-artifact@v4 - if: success() + if: steps.set_enabled.outputs.enabled == 'true' && success() with: name: (build) test-linux-musl-amd64 (${{ matrix.java_version }}, ${{ matrix.config }}) path: build/ - name: Upload failures uses: actions/upload-artifact@v4 - if: failure() + if: steps.set_enabled.outputs.enabled == 'true' && failure() with: name: failures-musl-${{ matrix.java_version }}-${{ matrix.config }}-amd64 path: failures_musl-${{ matrix.java_version }}-${{ matrix.config }}-amd64.txt - name: Prepare reports - if: always() + if: steps.set_enabled.outputs.enabled == 'true' && always() run: | .github/scripts/prepare_reports.sh - name: Upload unwinding reports uses: actions/upload-artifact@v4 - if: success() && matrix.config == 'debug' + if: steps.set_enabled.outputs.enabled == 'true' && success() && matrix.config == 'debug' with: name: (unwinding-reports) unwinding-linux-musl-amd64 (${{ matrix.java_version }}, ${{ matrix.config }}) path: unwinding-reports - name: Upload test reports uses: actions/upload-artifact@v4 - if: failure() + if: steps.set_enabled.outputs.enabled == 'true' && failure() with: name: (test-reports) test-linux-musl-amd64 (${{ matrix.java_version }}, ${{ matrix.config }}) path: test-reports @@ -357,17 +371,17 @@ jobs: exit 1 fi - name: Generate Unwinding Report - if: success() && matrix.config == 'debug' + if: steps.set_enabled.outputs.enabled == 'true' && success() && matrix.config == 'debug' run: | ./gradlew -PCI :ddprof-test:unwindingReport --no-daemon - name: Add Unwinding Report to Job Summary - if: success() && matrix.config == 'debug' && hashFiles('ddprof-test/build/reports/unwinding-summary.md') != '' + if: steps.set_enabled.outputs.enabled == 'true' && success() && matrix.config == 'debug' && hashFiles('ddprof-test/build/reports/unwinding-summary.md') != '' run: | echo "## 🔧 Unwinding Quality Report - ${{ matrix.java_version }} (aarch64)" >> $GITHUB_STEP_SUMMARY cat ddprof-test/build/reports/unwinding-summary.md >> $GITHUB_STEP_SUMMARY - name: Upload build artifacts uses: actions/upload-artifact@v4 - if: success() + if: steps.set_enabled.outputs.enabled == 'true' && success() with: name: (build) test-linux-glibc-aarch64 (${{ matrix.java_version }}, ${{ matrix.config }}) path: build/ @@ -378,18 +392,18 @@ jobs: name: failures-glibc-${{ matrix.java_version }}-${{ matrix.config }}-aarch64 path: failures_glibc-${{ matrix.java_version }}-${{ matrix.config }}-aarch64.txt - name: Prepare reports - if: always() + if: steps.set_enabled.outputs.enabled == 'true' && always() run: | .github/scripts/prepare_reports.sh - name: Upload unwinding reports uses: actions/upload-artifact@v4 - if: success() && matrix.config == 'debug' + if: steps.set_enabled.outputs.enabled == 'true' && success() && matrix.config == 'debug' with: name: (unwinding-reports) unwinding-linux-glibc-aarch64 (${{ matrix.java_version }}, ${{ matrix.config }}) path: unwinding-reports - name: Upload test reports uses: actions/upload-artifact@v4 - if: failure() + if: steps.set_enabled.outputs.enabled == 'true' && failure() with: name: (test-reports) test-linux-glibc-aarch64 (${{ matrix.java_version }}, ${{ matrix.config }}) path: test-reports @@ -406,8 +420,18 @@ jobs: labels: arm-4core-linux-ubuntu24.04 timeout-minutes: 180 steps: + - name: Set enabled flag + id: set_enabled + run: | + echo "enabled=true" >> $GITHUB_OUTPUT + if [[ "${{ matrix.java_version }}" =~ -zing ]]; then + if [[ "${{ matrix.config }}" != "release" ]] && [[ "${{ matrix.config }}" != "debug" ]]; then + echo "enabled=false" >> $GITHUB_OUTPUT + fi + fi - uses: actions/checkout@v3 - name: Cache Gradle Wrapper Binaries + if: steps.set_enabled.outputs.enabled == 'true' uses: actions/cache@v4 with: path: ~/.gradle/wrapper/dists @@ -415,6 +439,7 @@ jobs: restore-keys: | gradle-wrapper-${{ runner.os }}- - name: Cache Gradle User Home + if: steps.set_enabled.outputs.enabled == 'true' uses: actions/cache@v4 with: path: ~/.gradle/caches @@ -423,6 +448,7 @@ jobs: gradle-caches-${{ runner.os }}- - name: Setup cached JDK id: cache-jdk + if: steps.set_enabled.outputs.enabled == 'true' uses: ./.github/actions/setup_cached_java with: version: ${{ matrix.java_version }} @@ -437,8 +463,10 @@ jobs: restore-keys: | async-profiler-${{ runner.os }}- - name: Extract Versions + if: steps.set_enabled.outputs.enabled == 'true' uses: ./.github/actions/extract_versions - name: Test + if: steps.set_enabled.outputs.enabled == 'true' run: | set +e # the effective JAVA_VERSION is computed in the test_alpine_aarch64.sh script @@ -455,7 +483,7 @@ jobs: exit 1 fi - name: Generate Unwinding Report - if: success() && matrix.config == 'debug' + if: steps.set_enabled.outputs.enabled == 'true' && success() && matrix.config == 'debug' run: | docker run --cpus 4 --rm -v /tmp:/tmp -v "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}" -w "${GITHUB_WORKSPACE}" alpine:3.21 /bin/sh -c " \"$GITHUB_WORKSPACE/.github/scripts/unwinding_report_alpine_aarch64.sh\" \ @@ -463,35 +491,35 @@ jobs: \"${{ matrix.config }}\" \"${{ env.JAVA_HOME }}\" \"${{ env.JAVA_TEST_HOME }}\" " - name: Add Unwinding Report to Job Summary - if: success() && matrix.config == 'debug' && hashFiles('ddprof-test/build/reports/unwinding-summary.md') != '' + if: steps.set_enabled.outputs.enabled == 'true' && success() && matrix.config == 'debug' && hashFiles('ddprof-test/build/reports/unwinding-summary.md') != '' run: | echo "## 🔧 Unwinding Quality Report - ${{ matrix.java_version }} (aarch64-musl)" >> $GITHUB_STEP_SUMMARY cat ddprof-test/build/reports/unwinding-summary.md >> $GITHUB_STEP_SUMMARY - name: Upload build artifacts uses: actions/upload-artifact@v4 - if: success() + if: steps.set_enabled.outputs.enabled == 'true' && success() with: name: (build) test-linux-musl-aarch64 (${{ matrix.java_version }}, ${{ matrix.config }}) path: build/ - name: Upload failures uses: actions/upload-artifact@v4 - if: failure() + if: steps.set_enabled.outputs.enabled == 'true' && failure() with: name: failures-musl-${{ matrix.java_version }}-${{ matrix.config }}-aarch64 path: failures_musl-${{ matrix.java_version }}-${{ matrix.config }}-aarch64.txt - name: Prepare reports - if: always() + if: steps.set_enabled.outputs.enabled == 'true' && always() run: | .github/scripts/prepare_reports.sh - name: Upload unwinding reports uses: actions/upload-artifact@v4 - if: success() && matrix.config == 'debug' + if: steps.set_enabled.outputs.enabled == 'true' && success() && matrix.config == 'debug' with: name: (unwinding-reports) unwinding-linux-musl-aarch64 (${{ matrix.java_version }}, ${{ matrix.config }}) path: unwinding-reports - name: Upload test reports uses: actions/upload-artifact@v4 - if: failure() + if: steps.set_enabled.outputs.enabled == 'true' && failure() with: name: (test-reports) test-linux-musl-aarch64 (${{ matrix.java_version }}, ${{ matrix.config }}) path: test-reports From 82a0dd3bdfea7cdab9f53a782b4b9cca8587aabe Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Fri, 24 Oct 2025 17:11:01 +0200 Subject: [PATCH 4/4] Add suppression for ASAN issues in libjvm --- gradle/sanitizers/asan.supp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gradle/sanitizers/asan.supp b/gradle/sanitizers/asan.supp index e69de29bb..e643ece99 100644 --- a/gradle/sanitizers/asan.supp +++ b/gradle/sanitizers/asan.supp @@ -0,0 +1,3 @@ +# Suppress all AddressSanitizer errors in libjvm +# This is JVM internal code that we cannot fix +interceptor_via_lib:libjvm \ No newline at end of file