-
Notifications
You must be signed in to change notification settings - Fork 182
139 lines (125 loc) · 5.84 KB
/
Copy pathprof_asan.yml
File metadata and controls
139 lines (125 loc) · 5.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Profiling ASAN/UBSAN Tests
on:
pull_request:
permissions:
contents: read
jobs:
prof-asan:
name: PHP ${{ matrix.php-version }} ${{ matrix.php-build }} (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
php-version: [8.3, 8.4, 8.5]
php-build: [nts-asan, debug-zts-asan]
runner: [arm-8core-linux, ubuntu-8-core-latest]
env:
CARGO_HOME: /rust/cargo
RUSTUP_HOME: /rust/rustup
CARGO_TARGET_DIR: /tmp/build-cargo
RUST_TOOLCHAIN: nightly-2025-06-13
container:
image: datadog/dd-trace-ci:php-${{matrix.php-version}}_bookworm-10
# https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#user
options: --user root
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 1
submodules: true
- name: Cache Cargo dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
/rust/cargo/registry/index/
/rust/cargo/registry/cache/
/rust/cargo/registry/src/
/rust/cargo/git/db/
/rust/cargo/git/checkouts/
key: ${{ runner.os }}-${{ runner.arch }}-cargo-deps-asan-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Cargo target
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: /tmp/build-cargo/
key: ${{ runner.os }}-${{ runner.arch }}-cargo-target-asan-${{ matrix.php-version }}-${{ matrix.php-build }}-${{ env.RUST_TOOLCHAIN }}-${{ github.sha }}-${{ hashFiles('.github/workflows/prof_asan.yml') }}
- name: Build and install profiler
run: |
set -eux
switch-php ${{ matrix.php-build }}
cd profiling
export CC=clang-20
export CFLAGS='-fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer'
export LDFLAGS='-fsanitize=address -shared-libasan'
export RUSTC_LINKER=lld-20
triplet=$(uname -m)-unknown-linux-gnu
RUSTFLAGS='-Zsanitizer=address -C force-frame-pointers=yes' cargo +${RUST_TOOLCHAIN} build -Zbuild-std=std,panic_abort --target $triplet --profile profiler-release
cp -v "$CARGO_TARGET_DIR/$triplet/profiler-release/libdatadog_php_profiling.so" "$(php-config --extension-dir)/datadog-profiling.so"
- name: Run phpt tests
run: |
set -eux
switch-php ${{ matrix.php-build }}
cd profiling/tests
cp -v $(php-config --prefix)/lib/php/build/run-tests.php .
export DD_PROFILING_OUTPUT_PPROF=/tmp/pprof
export ASAN_OPTIONS="${ASAN_OPTIONS:+$ASAN_OPTIONS:}abort_on_error=1:halt_on_error=1:detect_leaks=1:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:detect_container_overflow=1:detect_odr_violation=2:symbolize=1:disable_coredump=0:unmap_shadow_on_exit=1"
export LSAN_OPTIONS="${LSAN_OPTIONS:+$LSAN_OPTIONS:}exitcode=23:print_suppressions=0:report_objects=1"
php run-tests.php -j$(nproc) --show-diff --asan -d extension=datadog-profiling.so phpt
prof-ubsan:
name: PHP 8.5 ${{ matrix.php-build }} UBSAN (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
strategy:
matrix:
php-build: [nts, zts]
runner: [arm-8core-linux, ubuntu-8-core-latest]
env:
CARGO_HOME: /rust/cargo
RUSTUP_HOME: /rust/rustup
CARGO_TARGET_DIR: /tmp/build-cargo
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
container:
image: datadog/dd-trace-ci:php-8.5_bookworm-10
options: --user root
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 1
submodules: true
- name: Cache Cargo dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
/rust/cargo/registry/index/
/rust/cargo/registry/cache/
/rust/cargo/registry/src/
/rust/cargo/git/db/
/rust/cargo/git/checkouts/
key: ${{ runner.os }}-${{ runner.arch }}-cargo-deps-c-ubsan-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Cargo target
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: /tmp/build-cargo/
key: ${{ runner.os }}-${{ runner.arch }}-cargo-target-c-ubsan-8.5-${{ matrix.php-build }}-${{ github.sha }}-${{ hashFiles('.github/workflows/prof_asan.yml') }}
- name: Build and install profiler
run: |
set -eux
switch-php ${{ matrix.php-build }}
cd profiling
export CC=clang-20
export CXX=clang++-20
export CFLAGS='-fsanitize=undefined,local-bounds -fno-sanitize-recover=all -fno-omit-frame-pointer'
export LDFLAGS='-fsanitize=undefined,local-bounds -fno-sanitize-recover=all'
export RUSTC_LINKER=clang-20
export RUSTFLAGS='-C link-arg=-fsanitize=undefined,local-bounds -C link-arg=-fno-sanitize-recover=all'
cargo build --profile profiler-release
cp -v "$CARGO_TARGET_DIR/profiler-release/libdatadog_php_profiling.so" "$(php-config --extension-dir)/datadog-profiling.so"
- name: Run phpt tests
run: |
set -eux
switch-php ${{ matrix.php-build }}
cd profiling/tests
cp -v $(php-config --prefix)/lib/php/build/run-tests.php .
export DD_PROFILING_OUTPUT_PPROF=/tmp/pprof
ubsan_runtime=$(clang-20 -print-file-name=libclang_rt.ubsan_standalone-$(uname -m).so)
export LD_PRELOAD="$ubsan_runtime${LD_PRELOAD:+:$LD_PRELOAD}"
php run-tests.php -j$(nproc) --show-diff -d extension=datadog-profiling.so phpt