run.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. set -euo pipefail
  3. dir=$(realpath "$(dirname "$0")")
  4. logs="$GITHUB_WORKSPACE/sanitizer"
  5. case "$SANITIZER" in
  6. undefined)
  7. flags='-fsanitize=integer -fsanitize=nullability -fno-sanitize=unsigned-integer-overflow'
  8. export UBSAN_OPTIONS="log_path=$logs/ubsan:print_stacktrace=1"
  9. ;;
  10. address)
  11. flags='-fsanitize-address-use-after-scope -fsanitize=pointer-compare -fsanitize=pointer-subtract'
  12. export ASAN_OPTIONS="log_path=$logs/asan:detect_invalid_pointer_pairs=2:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1"
  13. export LSAN_OPTIONS="suppressions=$dir/suppress.txt:print_suppressions=0"
  14. ;;
  15. thread)
  16. flags=''
  17. export TSAN_OPTIONS="log_path=$logs/tsan"
  18. ;;
  19. *)
  20. echo >&2 "unknown sanitizer $SANITIZER"
  21. exit 1
  22. ;;
  23. esac
  24. export CC='clang-12'
  25. export CPPFLAGS='-DDEBUG'
  26. export CFLAGS="-O0 -g -fsanitize=$SANITIZER -fno-omit-frame-pointer -fno-common -fsanitize-blacklist=$dir/ignore.txt $flags"
  27. bash .ci/test/run.sh "$@"
  28. # Check that the sanitizer has not created any log files.
  29. # If it has, fail the job to notify the developer.
  30. log_count=$(find "$logs" -type f -printf . | wc -c)
  31. if [ "$log_count" != 0 ]; then
  32. echo "expected zero sanitizer logs, found $log_count"
  33. exit 1
  34. fi