mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2026-04-19 02:28:43 +00:00
* fix: disable unsigned integer overflow sanitization in build configurations
FYI: from https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
`-fsanitize=unsigned-integer-overflow`: Unsigned integer overflow, where the result of an unsigned integer computation cannot be represented in its type. Unlike signed integer overflow, this is not undefined behavior, but it is often unintentional. This sanitizer does not check for lossy implicit conversions performed before such a computation.
It brings a more common question: which is better, pre-additional-check or post-additional-check to fix a potential unsigned integer overflow? A pre-additional-check involves using a check to prevent integer overflow from the very beginning. A post-additional-check involves using a check after addition to see if there is an overflow.
In this project, post-additional-checking is widely used. let's follow the routine.
for performance sensitive logic, use __builtin_add_overflow etc. provide something like 9a5622791e/lib/platform.h (L176-L191) and encourage the use of them.
ref. https://github.com/bytecodealliance/wasm-micro-runtime/pull/4549#issuecomment-3218687294
* fix: update AOT compiler configuration and enhance error handling in fuzz tests
32 lines
1.3 KiB
CMake
32 lines
1.3 KiB
CMake
if(NOT IN_OSS_FUZZ)
|
|
message(STATUS "Enable ASan and UBSan in non-oss-fuzz environment for vmlib")
|
|
|
|
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
|
|
|
|
#
|
|
# Sync up with the content of infra/base-images/base-builder/Dockerfile in oss-fuzz
|
|
#
|
|
|
|
# SANITIZER_FLAGS_address
|
|
add_compile_options(-fsanitize=address -fsanitize-address-use-after-scope)
|
|
|
|
# SANITIZER_FLAGS_undefined
|
|
add_compile_options(
|
|
-O1
|
|
-fsanitize=array-bounds,bool,builtin,enum,function,integer-divide-by-zero,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unsigned-integer-overflow,unreachable,vla-bound,vptr
|
|
-fno-sanitize-recover=array-bounds,bool,builtin,enum,function,integer-divide-by-zero,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr
|
|
)
|
|
|
|
add_link_options(-fsanitize=address,undefined -fprofile-instr-generate)
|
|
endif()
|
|
|
|
# Always disable unsigned-integer-overflow
|
|
if(CMAKE_C_COMPILER_ID MATCHES ".*Clang")
|
|
add_compile_options(-fno-sanitize=unsigned-integer-overflow)
|
|
endif()
|
|
|
|
# '-fsanitize=vptr' not allowed with '-fno-rtti
|
|
# But, LLVM by default, disables the use of `rtti` in the compiler
|
|
add_compile_options(-fsanitize=fuzzer -fno-sanitize=vptr)
|
|
add_link_options(-fsanitize=fuzzer -fno-sanitize=vptr)
|