Skip to content

Commit

Permalink
Add UBSAN and halt on error for sanitizers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Oct 5, 2024
1 parent 9d95d9e commit 4cefcf1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/CITest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ concurrency:

env:
CI: true
UBSAN_OPTIONS: "halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1"
ASAN_OPTIONS: "halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1"

jobs:
Linux:
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ option(ENABLE_COVERAGE "Enable test coverage" OFF)
if (ENABLE_ASAN)
message("Enabling ASAN")
add_definitions(-DASAN_ENABLED)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
add_compile_options(-fsanitize=address,undefined)
add_link_options(-fsanitize=address,undefined)
endif()

if (ENABLE_COVERAGE)
Expand Down
3 changes: 0 additions & 3 deletions SStream.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,6 @@ void printInt32(SStream *O, int32_t val)
SStream_concat(O, "%" PRId32, val);
} else {
if (val < -HEX_THRESHOLD) {
if (val == INT32_MIN)
SStream_concat(O, "-0x%" PRIx32, (uint32_t) INT32_MAX + 1);
else
SStream_concat(O, "-0x%" PRIx32, (int32_t)-val);
} else {
SStream_concat(O, "-%" PRIu32, (uint32_t)-val);
Expand Down

0 comments on commit 4cefcf1

Please sign in to comment.