Skip to content

Commit e59a5b3

Browse files
Feature/ubsan ubuntu (#545)
* UBSAN on Ubuntu Signed-off-by: Alexey Chernyshov <[email protected]>
1 parent c4e7d41 commit e59a5b3

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Known issue in RapidJSON library
2+
# (https://github.com/Tencent/rapidjson/issues/1724). Waiting for the next
3+
# release (https://github.com/Tencent/rapidjson/issues/1006).
4+
src:*rapidjson/internal/stack.h

.github/workflows/ubsan.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
build:
13-
runs-on: macOS-latest
13+
runs-on: ubuntu-20.04
1414
steps:
1515
- uses: actions/checkout@v2
1616
name: checkout repo
@@ -30,21 +30,24 @@ jobs:
3030
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
3131
- name: install
3232
run: |
33-
echo "LIBRARY_PATH=$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib" >> $GITHUB_ENV
34-
brew install ninja llvm pkg-config libb2 hwloc
33+
sudo apt-get update
34+
sudo apt-get install -y ninja-build python-setuptools pkg-config ocl-icd-* opencl-headers libhwloc-dev
3535
sudo python3 -m pip install --upgrade pip
3636
sudo python3 -m pip install scikit-build cmake requests gitpython gcovr pyyaml
3737
- name: cmake
3838
env:
39+
CC: "clang"
40+
CXX: "clang++"
41+
CFLAGS: -fsanitize-blacklist=${{ github.workspace }}/.github/workflows/ubsan-ignorelist.txt
42+
CXXFLAGS: -fsanitize-blacklist=${{ github.workspace }}/.github/workflows/ubsan-ignorelist.txt
3943
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # has to be included to access other secrets
4044
GITHUB_HUNTER_USERNAME: ${{ secrets.HUNTER_USERNAME }}
4145
GITHUB_HUNTER_TOKEN: ${{ secrets.HUNTER_TOKEN }}
42-
CFLAGS: "-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
43-
CXXFLAGS: "-isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
4446
run: cmake . -GNinja -Bbuild -D UBSAN=ON -D TESTING_PROOFS=ON -D TESTING_ACTORS=ON
4547
- name: build
4648
run: cmake --build build -- -j2
4749
- name: run tests
4850
env:
4951
CTEST_OUTPUT_ON_FAILURE: 1
52+
UBSAN_OPTIONS: "halt_on_error=1: print_stacktrace=1"
5053
run: cmake --build build --target test

test/core/vm/exit_code/exit_code_test.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
#include <gtest/gtest.h>
99

10-
enum SampleError {};
10+
enum SampleError {
11+
kSample = 1,
12+
};
1113
OUTCOME_HPP_DECLARE_ERROR(SampleError);
1214
OUTCOME_CPP_DEFINE_CATEGORY(SampleError, e) {
1315
return "sample error";
@@ -18,14 +20,15 @@ namespace fc::vm {
1820

1921
/// Distinguish VMExitCode errors from other errors
2022
TEST(VMExitCode, IsVMExitCode) {
21-
EXPECT_TRUE(isVMExitCode(failure(VMExitCode(1)).error()));
22-
EXPECT_FALSE(isVMExitCode(failure(SampleError(1)).error()));
23+
EXPECT_TRUE(
24+
isVMExitCode(failure(VMExitCode(SampleError::kSample)).error()));
25+
EXPECT_FALSE(isVMExitCode(failure(SampleError::kSample).error()));
2326
}
2427

2528
/// Distinguish VMFatal errors from other errors
2629
TEST(VMExitCode, IsFatal) {
2730
EXPECT_TRUE(isFatal(failure(VMFatal(VMFatal::kFatal)).error()));
28-
EXPECT_FALSE(isFatal(failure(SampleError(1)).error()));
31+
EXPECT_FALSE(isFatal(failure(SampleError::kSample).error()));
2932
}
3033

3134
/**
@@ -66,7 +69,7 @@ namespace fc::vm {
6669
TEST(VMExitCode, RequireNoErrorDefault) {
6770
VMExitCode default_exit_code{VMExitCode::kOk};
6871

69-
outcome::result<void> req{SampleError(1)};
72+
outcome::result<void> req{SampleError::kSample};
7073
auto res = requireNoError(req, default_exit_code);
7174
EXPECT_TRUE(isAbortExitCode(res.error()));
7275
EXPECT_FALSE(isVMExitCode(res.error()));

0 commit comments

Comments
 (0)