Add option to enable asan compilation in CS: --enable-asan (#3428)

Add workflow `ci-asan.yml` to test CS with ASAN as well.
This commit is contained in:
Paulo Matos 2020-10-07 17:18:56 +02:00 committed by GitHub
parent e93d1341fb
commit c5e3de2a7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 127 additions and 2 deletions

90
.github/workflows/ci-asan.yml vendored Normal file
View File

@ -0,0 +1,90 @@
name: Test with ASan
on: [push, pull_request]
jobs:
racketcs-asan:
runs-on: ubuntu-18.04
container: racket/racket-ci:latest
env:
ASAN_OPTIONS: 'halt_on_error=0,log_path=racket-asan'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 100
- name: Create logs directory
run: mkdir $PWD/logs
- name: Build
run: |
export cpus=$(grep -c ^processor /proc/cpuinfo)
make CPUS="${cpus}" PKGS="racket-test db-test unstable-flonum-lib net-test" CONFIGURE_ARGS_qq='--enable-asan' cs-in-place 2>&1 | tee logs/build.log
- name: Add new racket to PATH
# This should be:
# run: echo "::add-path::${{ github.workspace }}/racket/bin"
# but due to a github bug, the variable ${{ github.workspace }} value inside a container is broken
# so we hard code the real value
run: |
echo "::add-path::/__w/racket/racket/racket/bin"
find /__w/racket/racket/racket/bin -type f
- name: Racket version
run: |
which racket
racket --version
- name: Run tests/racket/test
continue-on-error: true
run: raco test -l tests/racket/test
- name: Run tests/racket/contract/all
continue-on-error: true
run: racket -l tests/racket/contract/all
- name: Run tests/json/json
continue-on-error: true
run: raco test -l tests/json/json
- name: Run tests/file/main
continue-on-error: true
run: raco test -l tests/file/main
- name: Run tests/net/head
continue-on-error: true
run: raco test -l tests/net/head
- name: Run tests/net/uri-codec
continue-on-error: true
run: raco test -l tests/net/uri-codec
- name: Run tests/net/url
continue-on-error: true
run: raco test -l tests/net/url
- name: Run tests/net/url-port
continue-on-error: true
run: raco test -l tests/net/url-port
- name: Run tests/net/encoders
continue-on-error: true
run: raco test -l tests/net/encoders
- name: Run tests/openssl/basic
continue-on-error: true
run: raco test -l tests/openssl/basic
- name: Run tests/openssl/https
continue-on-error: true
run: raco test -l tests/openssl/https
- name: Run tests/match/main
continue-on-error: true
run: raco test -l tests/match/main
- name: Run tests/zo-path
continue-on-error: true
run: raco test -l tests/zo-path
- name: Run tests/xml
continue-on-error: true
run: raco test -c tests/xml
- name: Run tests/future
continue-on-error: true
run: raco test -c tests/future
- name: Run tests/stxparse
continue-on-error: true
run: raco test -c tests/stxparse
- name: Run db tests
continue-on-error: true
run: raco test -l tests/db/all-tests
- uses: actions/upload-artifact@v2
with:
name: asan-errors-cs_git${{ github.sha }}
path: ./racket-asan.*

View File

@ -1,11 +1,11 @@
name: Test with Sanitizers
name: Test with UBSan
on: [push, pull_request]
jobs:
# Build jobs
# These jobs build Racket using the sanitizers and gather the results into a final log
# These jobs build Racket using undefined behaviour sanitizers and gathers the results into a final log
racket3m-ubsan:
runs-on: ubuntu-18.04
container: racket/racket-ci:latest
@ -178,3 +178,4 @@ jobs:
with:
name: runtime-errors-cs_git${{ github.sha }}
path: runtime-errors_git${{ github.sha }}.log

8
racket/src/ac/asan.m4 Normal file
View File

@ -0,0 +1,8 @@
if test "${enable_asan}" = "yes" ; then
ASAN="-fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer -fno-common"
CFLAGS="$CFLAGS $ASAN"
CPPFLAGS="$CPPFLAGS $ASAN"
PREFLAGS="$PREFLAGS $ASAN"
LDFLAGS="$LDFLAGS $ASAN"
fi

View File

@ -0,0 +1 @@
AC_ARG_ENABLE(asan, [ --enable-asan compile with -fsanitize=address])

View File

@ -796,6 +796,7 @@ enable_mac64
enable_libs
enable_noopt
enable_ubsan
enable_asan
enable_bcdefault
enable_csonly
enable_csdefault
@ -1446,6 +1447,7 @@ Optional Features:
--enable-libs install static libraries (enabled by default for Unix)
--enable-strip strip debug on install (usually enabled by default)
--enable-ubsan compile with -fsanitize=undefined
--enable-asan compile with -fsanitize=address
--enable-bcdefault install BC without suffix
--enable-bconly BC default, and skip CS build
--enable-csdefault install CS without suffix
@ -2679,6 +2681,12 @@ if test "${enable_ubsan+set}" = set; then :
fi
# Check whether --enable-asan was given.
if test "${enable_asan+set}" = set; then :
enableval=$enable_asan;
fi
# Check whether --enable-bcdefault was given.
if test "${enable_bcdefault+set}" = set; then :
enableval=$enable_bcdefault;
@ -4727,6 +4735,18 @@ if test "${enable_ubsan}" = "yes" ; then
fi
############## ubsan ################
if test "${enable_asan}" = "yes" ; then
ASAN="-fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer -fno-common"
CFLAGS="$CFLAGS $ASAN"
CPPFLAGS="$CPPFLAGS $ASAN"
PREFLAGS="$PREFLAGS $ASAN"
LDFLAGS="$LDFLAGS $ASAN"
fi
############## Makefile includes ################
if test "$INCLUDEDEP" = "#" ; then

View File

@ -28,6 +28,7 @@ m4_include(../ac/sdk_arg.m4)
m4_include(../ac/instlib_arg.m4)
m4_include(../ac/strip_arg.m4)
m4_include(../ac/ubsan_arg.m4)
m4_include(../ac/asan_arg.m4)
m4_include(../ac/vm_arg.m4)
m4_include(../ac/crossany_arg.m4)
AC_ARG_ENABLE(libz, [ --enable-libz use installed libz if available])
@ -470,6 +471,10 @@ fi
m4_include(../ac/ubsan.m4)
############## ubsan ################
m4_include(../ac/asan.m4)
############## Makefile includes ################
if test "$INCLUDEDEP" = "#" ; then