Skip to content

Commit 72c5f4c

Browse files
authored
Merge pull request #11823 from ethereum/fix-11822
Add UBSan build + test nightly CI.
2 parents 7df33f0 + b77d345 commit 72c5f4c

File tree

2 files changed

+132
-68
lines changed

2 files changed

+132
-68
lines changed

.circleci/config.yml

Lines changed: 97 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,7 @@ defaults:
121121
no_output_timeout: 30m
122122
command: ./.circleci/soltest_all.sh
123123

124-
- run_cmdline_tests: &run_cmdline_tests
125-
name: command line tests
126-
no_output_timeout: 30m
127-
command: ./test/cmdlineTests.sh
128-
129-
- run_docs_pragma_min_version: &run_docs_pragma_min_version
130-
name: docs pragma version check
131-
command: ./scripts/docs_version_pragma_check.sh
132-
133-
- test_ubuntu1604_clang: &test_ubuntu1604_clang
134-
docker:
135-
- image: << pipeline.parameters.ubuntu-1604-clang-ossfuzz-docker-image >>
124+
- run_soltest_steps: &run_soltest_steps
136125
steps:
137126
- checkout
138127
- attach_workspace:
@@ -141,50 +130,57 @@ defaults:
141130
- store_test_results: *store_test_results
142131
- store_artifacts: *artifacts_test_results
143132

144-
- test_ubuntu2004_clang: &test_ubuntu2004_clang
145-
docker:
146-
- image: << pipeline.parameters.ubuntu-2004-clang-docker-image >>
133+
- run_soltest_all_steps: &run_soltest_all_steps
147134
steps:
148135
- checkout
149136
- attach_workspace:
150137
at: build
151-
- run: *run_soltest
138+
- run: *run_soltest_all
152139
- store_test_results: *store_test_results
153140
- store_artifacts: *artifacts_test_results
154141

155-
- test_ubuntu2004: &test_ubuntu2004
156-
docker:
157-
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
158-
parallelism: 6
142+
- run_cmdline_tests: &run_cmdline_tests
143+
name: command line tests
144+
no_output_timeout: 30m
145+
command: ./test/cmdlineTests.sh
146+
147+
- run_cmdline_tests_steps: &run_cmdline_tests_steps
159148
steps:
160149
- checkout
161150
- attach_workspace:
162151
at: build
163-
- run: *run_soltest_all
152+
- run: *run_cmdline_tests
164153
- store_test_results: *store_test_results
165154
- store_artifacts: *artifacts_test_results
166155

156+
- run_docs_pragma_min_version: &run_docs_pragma_min_version
157+
name: docs pragma version check
158+
command: ./scripts/docs_version_pragma_check.sh
159+
160+
- test_ubuntu1604_clang: &test_ubuntu1604_clang
161+
docker:
162+
- image: << pipeline.parameters.ubuntu-1604-clang-ossfuzz-docker-image >>
163+
<<: *run_soltest_steps
164+
165+
- test_ubuntu2004_clang: &test_ubuntu2004_clang
166+
docker:
167+
- image: << pipeline.parameters.ubuntu-2004-clang-docker-image >>
168+
<<: *run_soltest_steps
169+
170+
- test_ubuntu2004: &test_ubuntu2004
171+
docker:
172+
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
173+
parallelism: 6
174+
<<: *run_soltest_all_steps
175+
167176
- test_asan: &test_asan
168177
<<: *test_ubuntu2004
169-
steps:
170-
- checkout
171-
- attach_workspace:
172-
at: build
173-
- run:
174-
<<: *run_soltest
175-
- store_test_results: *store_test_results
176-
- store_artifacts: *artifacts_test_results
178+
<<: *run_soltest_steps
177179

178-
- test_asan_clang: &test_asan_clang
179-
<<: *test_ubuntu2004_clang
180-
steps:
181-
- checkout
182-
- attach_workspace:
183-
at: build
184-
- run:
185-
<<: *run_soltest
186-
- store_test_results: *store_test_results
187-
- store_artifacts: *artifacts_test_results
180+
- test_ubuntu2004_clang_cli: &test_ubuntu2004_clang_cli
181+
docker:
182+
- image: << pipeline.parameters.ubuntu-2004-clang-docker-image >>
183+
<<: *run_cmdline_tests_steps
188184

189185
# --------------------------------------------------------------------------
190186
# Workflow Templates
@@ -239,6 +235,11 @@ defaults:
239235
requires:
240236
- b_ubu_asan_clang
241237

238+
- workflow_ubuntu2004_ubsan_clang: &workflow_ubuntu2004_ubsan_clang
239+
<<: *workflow_trigger_on_tags
240+
requires:
241+
- b_ubu_ubsan_clang
242+
242243
- workflow_emscripten: &workflow_emscripten
243244
<<: *workflow_trigger_on_tags
244245
requires:
@@ -433,7 +434,7 @@ jobs:
433434
name: Python unit tests
434435
command: python.exe test/pyscriptTests.py
435436

436-
b_ubu_clang: &build_ubuntu2004_clang
437+
b_ubu_clang: &b_ubu_clang
437438
resource_class: xlarge
438439
docker:
439440
- image: << pipeline.parameters.ubuntu-2004-clang-docker-image >>
@@ -447,8 +448,7 @@ jobs:
447448
- store_artifacts: *artifacts_solc
448449
- persist_to_workspace: *artifacts_executables
449450

450-
451-
b_ubu_asan_clang: &build_ubuntu2004_clang
451+
b_ubu_asan_clang: &b_ubu_asan_clang
452452
docker:
453453
- image: << pipeline.parameters.ubuntu-2004-clang-docker-image >>
454454
environment:
@@ -462,7 +462,22 @@ jobs:
462462
- store_artifacts: *artifacts_solc
463463
- persist_to_workspace: *artifacts_executables
464464

465-
b_ubu: &build_ubuntu2004
465+
b_ubu_ubsan_clang: &b_ubu_ubsan_clang
466+
docker:
467+
- image: << pipeline.parameters.ubuntu-2004-clang-docker-image >>
468+
environment:
469+
CC: clang
470+
CXX: clang++
471+
CMAKE_OPTIONS: -DSANITIZE=undefined
472+
MAKEFLAGS: -j 3
473+
steps:
474+
- checkout
475+
- run: *run_build
476+
- run: *gitter_notify_failure
477+
- store_artifacts: *artifacts_solc
478+
- persist_to_workspace: *artifacts_executables
479+
480+
b_ubu: &b_ubu
466481
resource_class: xlarge
467482
docker:
468483
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
@@ -475,14 +490,14 @@ jobs:
475490
- store_artifacts: *artifacts_tools
476491
- persist_to_workspace: *artifacts_executables
477492

478-
b_ubu_release: &build_ubuntu2004_release
479-
<<: *build_ubuntu2004
493+
b_ubu_release: &b_ubu_release
494+
<<: *b_ubu
480495
environment:
481496
FORCE_RELEASE: ON
482497
MAKEFLAGS: -j 10
483498

484499
b_ubu_static:
485-
<<: *build_ubuntu2004
500+
<<: *b_ubu
486501
environment:
487502
MAKEFLAGS: -j 10
488503
CMAKE_OPTIONS: -DCMAKE_BUILD_TYPE=Release -DUSE_Z3_DLOPEN=ON -DUSE_CVC4=OFF -DSOLC_STATIC_STDLIBS=ON
@@ -495,7 +510,7 @@ jobs:
495510
- store_artifacts: *artifacts_solc
496511

497512
b_ubu_codecov:
498-
<<: *build_ubuntu2004
513+
<<: *b_ubu
499514
environment:
500515
COVERAGE: ON
501516
CMAKE_BUILD_TYPE: Debug
@@ -529,7 +544,7 @@ jobs:
529544
# Builds in C++20 mode and uses debug build in order to speed up.
530545
# Do *NOT* store any artifacts or workspace as we don't run tests on this build.
531546
b_ubu_cxx20:
532-
<<: *build_ubuntu2004
547+
<<: *b_ubu
533548
environment:
534549
CMAKE_BUILD_TYPE: Debug
535550
CMAKE_OPTIONS: -DCMAKE_CXX_STANDARD=20 -DUSE_CVC4=OFF
@@ -538,7 +553,7 @@ jobs:
538553
- checkout
539554
- run: *run_build
540555

541-
b_ubu_ossfuzz: &build_ubuntu1604_clang
556+
b_ubu_ossfuzz: &b_ubu_ossfuzz
542557
docker:
543558
- image: << pipeline.parameters.ubuntu-1604-clang-ossfuzz-docker-image >>
544559
environment:
@@ -683,7 +698,7 @@ jobs:
683698

684699
# x64 ASAN build, for testing for memory related bugs
685700
b_ubu_asan: &b_ubu_asan
686-
<<: *build_ubuntu2004
701+
<<: *b_ubu
687702
environment:
688703
CMAKE_OPTIONS: -DSANITIZE=address
689704
MAKEFLAGS: -j 10
@@ -768,13 +783,7 @@ jobs:
768783
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
769784
environment:
770785
TERM: xterm
771-
steps:
772-
- checkout
773-
- attach_workspace:
774-
at: build
775-
- run: *run_cmdline_tests
776-
- store_test_results: *store_test_results
777-
- store_artifacts: *artifacts_test_results
786+
<<: *run_cmdline_tests_steps
778787

779788
t_ubu_release_cli: &t_ubu_release_cli
780789
<<: *t_ubu_cli
@@ -784,14 +793,7 @@ jobs:
784793
environment:
785794
TERM: xterm
786795
ASAN_OPTIONS: check_initialization_order=true:detect_stack_use_after_return=true:strict_init_order=true:strict_string_checks=true:detect_invalid_pointer_pairs=2
787-
steps:
788-
- checkout
789-
- attach_workspace:
790-
at: build
791-
- run:
792-
<<: *run_cmdline_tests
793-
- store_test_results: *store_test_results
794-
- store_artifacts: *artifacts_test_results
796+
<<: *run_cmdline_tests_steps
795797

796798
t_ubu_asan_constantinople:
797799
<<: *test_asan
@@ -802,13 +804,37 @@ jobs:
802804
ASAN_OPTIONS: check_initialization_order=true:detect_stack_use_after_return=true:strict_init_order=true:strict_string_checks=true:detect_invalid_pointer_pairs=2
803805

804806
t_ubu_asan_constantinople_clang:
805-
<<: *test_asan_clang
807+
<<: *test_ubuntu2004_clang
806808
environment:
807809
EVM: constantinople
808810
OPTIMIZE: 0
809811
SOLTEST_FLAGS: --no-smt
810812
ASAN_OPTIONS: check_initialization_order=true:detect_stack_use_after_return=true:strict_init_order=true:strict_string_checks=true:detect_invalid_pointer_pairs=2
811813

814+
t_ubu_ubsan_clang:
815+
docker:
816+
- image: << pipeline.parameters.ubuntu-2004-clang-docker-image >>
817+
steps:
818+
- checkout
819+
- attach_workspace:
820+
at: build
821+
- run: *run_soltest
822+
- run: *gitter_notify_failure
823+
- store_test_results: *store_test_results
824+
- store_artifacts: *artifacts_test_results
825+
826+
t_ubu_ubsan_clang_cli:
827+
docker:
828+
- image: << pipeline.parameters.ubuntu-2004-clang-docker-image >>
829+
steps:
830+
- checkout
831+
- attach_workspace:
832+
at: build
833+
- run: *run_cmdline_tests
834+
- run: *gitter_notify_failure
835+
- store_test_results: *store_test_results
836+
- store_artifacts: *artifacts_test_results
837+
812838
t_ems_solcjs:
813839
docker:
814840
- image: << pipeline.parameters.ubuntu-2004-docker-image >>
@@ -1208,6 +1234,11 @@ workflows:
12081234
- t_ubu_asan_constantinople_clang: *workflow_ubuntu2004_asan_clang
12091235
- t_ubu_asan_cli: *workflow_ubuntu2004_asan
12101236

1237+
# UBSan build and tests
1238+
- b_ubu_ubsan_clang: *workflow_trigger_on_tags
1239+
- t_ubu_ubsan_clang: *workflow_ubuntu2004_ubsan_clang
1240+
- t_ubu_ubsan_clang_cli: *workflow_ubuntu2004_ubsan_clang
1241+
12111242
# Emscripten build and tests that take more than 15 minutes to execute
12121243
- b_ems: *workflow_trigger_on_tags
12131244
- t_ems_ext:

cmake/EthCompilerSettings.cmake

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,44 @@ endif ()
192192

193193
if (SANITIZE)
194194
# Perform case-insensitive string compare
195-
string(TOLOWER "${SANITIZE}" san)
195+
string(TOLOWER "${SANITIZE}" sanitizer)
196196
# -fno-omit-frame-pointer gives more informative stack trace in case of an error
197197
# -fsanitize-address-use-after-scope throws an error when a variable is used beyond its scope
198-
if (san STREQUAL "address")
198+
if (sanitizer STREQUAL "address")
199199
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address -fsanitize-address-use-after-scope")
200+
elseif (sanitizer STREQUAL "undefined")
201+
# The following flags not used by fuzzer but used by us may create problems, so consider
202+
# disabling them: alignment, pointer-overflow, unsigned-shift-base.
203+
# Flags are alphabetically sorted
204+
list(APPEND undefinedSanitizerChecks
205+
alignment
206+
array-bounds
207+
bool
208+
builtin
209+
enum
210+
float-divide-by-zero
211+
function
212+
integer-divide-by-zero
213+
null
214+
object-size
215+
pointer-overflow
216+
return
217+
returns-nonnull-attribute
218+
shift
219+
signed-integer-overflow
220+
unsigned-integer-overflow
221+
unsigned-shift-base
222+
unreachable
223+
vla-bound
224+
vptr
225+
)
226+
list(JOIN undefinedSanitizerChecks "," sanitizerChecks)
227+
list(REMOVE_ITEM undefinedSanitizerChecks unsigned-integer-overflow)
228+
# The fuzzer excludes reports of unsigned-integer-overflow. Hence, we remove it
229+
# from the -fno-sanitize-recover checks. Consider reducing this list if we do not
230+
# want to be notified about other failed checks.
231+
list(JOIN undefinedSanitizerChecks "," dontRecoverFromChecks)
232+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${sanitizerChecks} -fno-sanitize-recover=${dontRecoverFromChecks}")
200233
endif()
201234
endif()
202235

0 commit comments

Comments
 (0)