From 659741bb5852d23ed6359ff420cb3db7f38d34cb Mon Sep 17 00:00:00 2001 From: xxyzz Date: Tue, 22 Sep 2020 13:57:32 +0000 Subject: [PATCH] bc: declare interntional unsafe fixnum arithmetic Eliminate overflow errors from fixnum test when racket bc compiled with --enable-ubsan (issue #2314) --- .github/workflows/ci-ubsan.yml | 4 +++- racket/src/bc/src/numarith.c | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-ubsan.yml b/.github/workflows/ci-ubsan.yml index c7e7354479..57c55e2a10 100644 --- a/.github/workflows/ci-ubsan.yml +++ b/.github/workflows/ci-ubsan.yml @@ -84,7 +84,9 @@ jobs: continue-on-error: true run: raco test -l tests/db/all-tests | tee logs/db-all-tests.log - name: Gather runtime errors - run: grep 'runtime error' logs/*.log > runtime-errors_git${{ github.sha }}.log + run: | + grep 'runtime error' logs/*.log > runtime-errors_git${{ github.sha }}.log || true + test ! -s runtime-errors_git${{ github.sha }}.log - uses: actions/upload-artifact@v2 with: name: runtime-errors_git${{ github.sha }} diff --git a/racket/src/bc/src/numarith.c b/racket/src/bc/src/numarith.c index 0da581b917..56e8ef08f0 100644 --- a/racket/src/bc/src/numarith.c +++ b/racket/src/bc/src/numarith.c @@ -1228,7 +1228,14 @@ static Scheme_Object *fx_abs(int argc, Scheme_Object *argv[]) return o; } -#define UNSAFE_FX(name, op, fold, zero_args, PRE_CHECK) \ +#if __GNUC__ >= 8 || __clang_major__ >= 4 +# define NO_SANITIZE_SIGNED_INTEGER_OVERFLOW \ + __attribute__((no_sanitize("signed-integer-overflow"))) +#else +# define NO_SANITIZE_SIGNED_INTEGER_OVERFLOW +#endif +#define UNSAFE_FX(name, op, fold, zero_args, PRE_CHECK) \ + NO_SANITIZE_SIGNED_INTEGER_OVERFLOW \ static Scheme_Object *name(int argc, Scheme_Object *argv[]) \ { \ intptr_t v; \