Skip to content

Commit 34f412b

Browse files
authored
Merge pull request #590 from wasmx/sanitizers_config
Extend ASan checks
2 parents bfcd177 + abbe6a6 commit 34f412b

5 files changed

Lines changed: 24 additions & 89 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ if(WEVERYTHING)
6666
)
6767
endif()
6868

69+
if(SANITIZE MATCHES address)
70+
# Enables ASan-powered checks in std::vector in libstdc++.
71+
# For sanity, this may be applied for libstdc++ builds, but it is not easy to detect
72+
# what standard library implementation is being used.
73+
add_compile_definitions(_GLIBCXX_SANITIZE_VECTOR)
74+
endif()
75+
6976
# An option to enable assertions in non-Debug build types.
7077
# Disabling assertions in Debug build type has no effect (assertions are still enabled).
7178
option(ENABLE_ASSERTIONS "Enable NDEBUG based assertions" OFF)
@@ -83,7 +90,7 @@ if(ENABLE_ASSERTIONS)
8390
endif()
8491

8592
if(FIZZY_FUZZING)
86-
set(fuzzing_flags -fsanitize=fuzzer-no-link,address,undefined,nullability,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation)
93+
set(fuzzing_flags -fsanitize=fuzzer-no-link,address,pointer-subtract,undefined,nullability,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation)
8794
add_compile_options(${fuzzing_flags})
8895
add_link_options(${fuzzing_flags})
8996
endif()

circle.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ commands:
118118
- ~/.hunter/_Base/Cache
119119
- run:
120120
name: "Build <<parameters.configuration_name>> (<<parameters.build_type>>)"
121-
command: cmake --build ~/build --target <<parameters.target>> -- -j12
121+
command: cmake --build ~/build --target <<parameters.target>> -- -j6
122122

123123
test:
124124
description: "Test"
@@ -233,6 +233,7 @@ commands:
233233
working_directory: ~/build
234234
command: |
235235
set +e
236+
export ASAN_OPTIONS=detect_invalid_pointer_pairs=1 # TODO: value 2 causes failures in standard library.
236237
expected=" PASSED <<parameters.expected_passed>>, FAILED <<parameters.expected_failed>>, SKIPPED <<parameters.expected_skipped>>."
237238
result=$(bin/fizzy-spectests <<#parameters.skip_validation>>--skip-validation<</parameters.skip_validation>> json | tail -1)
238239
echo $result
@@ -361,16 +362,19 @@ jobs:
361362
destination: coverage
362363
- upload_coverage_data
363364

364-
sanitizers:
365+
sanitizers-clang:
365366
executor: linux-clang-latest
366367
environment:
368+
# TODO: Enable detect_stack_use_after_return=1 when https://bugs.llvm.org/show_bug.cgi?id=47626 is fixed.
369+
ASAN_OPTIONS: detect_invalid_pointer_pairs=2
367370
UBSAN_OPTIONS: halt_on_error=1
368371
steps:
369372
- install_testfloat
370373
- checkout
371374
- build:
372375
build_type: RelWithDebInfo
373-
cmake_options: -DENABLE_ASSERTIONS=ON -DSANITIZE=address,undefined,nullability,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation
376+
# TODO: pointer-compare produces failure in std::string operator+.
377+
cmake_options: -DENABLE_ASSERTIONS=ON -DSANITIZE=address,pointer-subtract,undefined,nullability,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation
374378
- test
375379
- benchmark:
376380
min_time: "0.01"
@@ -379,13 +383,16 @@ jobs:
379383
sanitizers-macos:
380384
executor: macos
381385
environment:
386+
# TODO: Enable detect_stack_use_after_return=1 when https://bugs.llvm.org/show_bug.cgi?id=47626 is fixed.
387+
ASAN_OPTIONS: detect_invalid_pointer_pairs=2
382388
UBSAN_OPTIONS: halt_on_error=1
383389
steps:
384390
- install_macos_deps
385391
- checkout
386392
- build:
387393
build_type: RelWithDebInfo
388-
cmake_options: -DENABLE_ASSERTIONS=ON -DSANITIZE=address,undefined,nullability,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation
394+
# TODO: pointer-compare produces failure in std::string operator+.
395+
cmake_options: -DENABLE_ASSERTIONS=ON -DSANITIZE=address,pointer-subtract,undefined,nullability,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation
389396
- test
390397
- benchmark:
391398
min_time: "0.01"
@@ -448,6 +455,8 @@ jobs:
448455
fuzzing:
449456
executor: linux-clang-latest
450457
environment:
458+
# TODO: Enable detect_stack_use_after_return=1 when https://bugs.llvm.org/show_bug.cgi?id=47626 is fixed.
459+
ASAN_OPTIONS: detect_invalid_pointer_pairs=2
451460
UBSAN_OPTIONS: halt_on_error=1
452461
steps:
453462
- checkout
@@ -474,7 +483,7 @@ jobs:
474483
MAX_LEN=100
475484
476485
# Invisible background jobs:
477-
bin/fizzy-fuzz-parser corpus-local -runs=$RUNS -max_len=$MAX_LEN -len_control=100000 -use_value_profile=1 -verbosity=0 -jobs=5 2>/dev/null &
486+
bin/fizzy-fuzz-parser corpus-local -runs=$RUNS -max_len=$MAX_LEN -len_control=100000 -use_value_profile=1 -verbosity=0 -jobs=4 2>/dev/null &
478487
479488
# Main job, to see logs:
480489
bin/fizzy-fuzz-parser corpus-local -runs=$RUNS -max_len=$MAX_LEN -len_control=100000 -use_value_profile=1 -print_final_stats=1
@@ -584,7 +593,7 @@ workflows:
584593
- sanitizers-macos
585594
- coverage-gcc
586595
- coverage-clang
587-
- sanitizers
596+
- sanitizers-clang
588597
- sanitizers-macos
589598
- fuzzing
590599
- spectest:

cmake/ProjectWabt.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set(wabt_library ${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}wabt${CMAKE_STATIC_
1414
set(flags -fvisibility=hidden)
1515
if(SANITIZE MATCHES address)
1616
# Instrument WABT with ASan - required for container-overflow checks.
17-
set(flags "-fsanitize=address ${flags}")
17+
set(flags "-D_GLIBCXX_SANITIZE_VECTOR -fsanitize=address ${flags}")
1818
endif()
1919

2020
if(CMAKE_GENERATOR MATCHES Ninja)

test/bench_internal/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ add_executable(fizzy-bench-internal)
66

77
target_sources(fizzy-bench-internal PRIVATE
88
bench_internal.cpp
9-
execute_benchmarks.cpp
109
experimental.cpp
1110
experimental.hpp
1211
parser_benchmarks.cpp

test/bench_internal/execute_benchmarks.cpp

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)