ci: run sanitizers #36
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Sanitizers | |
on: | |
pull_request: | |
branches: | |
- main | |
paths-ignore: | |
- "docs/**" | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- "docs/**" | |
permissions: | |
contents: read | |
jobs: | |
# Adapted from https://github.com/beberlei/hdrhistogram-php | |
sanitizers: | |
runs-on: ubuntu-latest | |
env: | |
CFLAGS: -g -O0 -fsanitize=address -DZEND_TRACK_ARENA_ALLOC | |
LDFLAGS: -fsanitize=address | |
CC: clang | |
CXX: clang++ | |
steps: | |
- | |
name: Remove local PHP | |
run: sudo apt-get remove --purge --autoremove 'php*' 'libmemcached*' | |
- | |
uses: actions/checkout@v4 | |
- | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.22" | |
cache-dependency-path: | | |
go.sum | |
caddy/go.sum | |
#- | |
# name: Install LLVM | |
# run: sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" | |
- | |
name: Determine PHP version | |
id: determine-php-version | |
run: | | |
curl -fsSL 'https://www.php.net/releases/index.php?json&max=1&version=8.3' -o version.json | |
echo version="$(jq -r 'keys[0]') version.json" >> "$GITHUB_OUTPUT" | |
echo archive="$(jq -r '.[] .source[] | select(.filename |endswith(".xz")) | "https://www.php.net/distributions/" + .filename' version.json)" >> "$GITHUB_OUTPUT" | |
#- | |
# name: Cache PHP | |
# id: cache-php | |
# uses: actions/cache@v4 | |
# with: | |
# path: php/target | |
# key: php-sanitizers-${{ runner.arch }}-${{ steps.determine-php-version.outputs.version }} | |
- | |
#if: steps.cache-php.outputs.cache-hit != 'true' | |
name: Compile PHP | |
run: | | |
mkdir php/ | |
curl -fsSL "${{ steps.determine-php-version.outputs.archive }}" | tar -Jx -C php --strip-components=1 | |
cd php/ | |
./configure \ | |
--enable-debug \ | |
--enable-embed \ | |
--enable-zts \ | |
--disable-zend-signals \ | |
--disable-cli \ | |
--disable-cgi \ | |
--disable-phpdbg | |
#--prefix="$(pwd)/target/" | |
make -j"$(getconf _NPROCESSORS_ONLN)" | |
sudo make install | |
#- | |
# name: Add PHP to the PATH | |
# run: | | |
# echo "$(pwd)/php/target/bin" >> "$GITHUB_PATH" | |
- | |
name: Set environement variables | |
run: | | |
{ | |
#echo "LIBRARY_PATH=$LIBRARY_PATH:$(pwd)/php/target/lib" | |
# https://github.com/google/sanitizers/wiki/AddressSanitizerAsDso | |
#echo "LD_PRELOAD=$($CC -print-file-name=libclang_rt.asan-x86_64.so)" | |
echo "CGO_CFLAGS=$CFLAGS $(php-config --includes)" | |
echo "CGO_LDLAGS=$LDFLAGS $(php-config --ldflags) $(php-config --libs)" | |
} >> "$GITHUB_ENV" | |
- | |
name: Clear ld.so.cache | |
run: | | |
sudo rm /etc/ld.so.cache | |
sudo ldconfig | |
- | |
name: Run library tests with ASAN | |
#env: | |
# LSAN_OPTIONS: suppressions=suppr.txt | |
run: | | |
#echo 'leak:libbfd' > suppr.txt | |
#echo 'leak:linux-gnu-ld.bfd' >> suppr.txt | |
go test -asan -v ./... | |
- | |
name: Run library tests with MSAN | |
run: go test -msan -v ./... |