Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,5 @@ CheckOptions:
value: true
- key: misc-const-correctness.WarnPointersAsValues
value: true
- key: misc-const-correctness.WarnPointersAsPointers
value: false
48 changes: 22 additions & 26 deletions .github/actions/check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,33 @@ runs:
working-directory: source-repo
shell: bash
run: |
set -ex
dirs="${{ inputs.cspell-dirs }}"
echo "$dirs"
dirs=$(if [ "$dirs" = "*" ]; then echo "**"; else echo "$dirs"; fi)
dirs=$(echo "$dirs" | sed "s/;$//" | sed "s/;;*/,/g")
if [[ "$dirs" == *","* ]]; then
dirs="{$dirs}"
fi
cspell --config ${{ inputs.cspell-config }} "$dirs/**/*.{h,c,hpp,cpp,cc,ipp}"
set -ex
dirs="${{ inputs.cspell-dirs }}"
echo "$dirs"
dirs=$(if [ "$dirs" = "*" ]; then echo "**"; else echo "$dirs"; fi)
dirs=$(echo "$dirs" | sed "s/;$//" | sed "s/;;*/,/g")
if [[ "$dirs" == *","* ]]; then
dirs="{$dirs}"
fi
cspell --config ${{ inputs.cspell-config }} "$dirs/**/*.{h,c,hpp,cpp,cc,ipp}"

- name: clang-format
if: inputs.clang-format == true
working-directory: source-repo
shell: bash
run: |
set -ex
dirs="${{ inputs.clang-format-dirs }}"
dirs=$(echo "$dirs" | tr ";" " ")
find $dirs -regex ".*\\.\\(cpp\\|hpp\\|c\\|h\\|ipp\\)" | xargs clang-format -style=file --Werror --dry-run -i
set -ex
dirs="${{ inputs.clang-format-dirs }}"
dirs=$(echo "$dirs" | tr ";" " ")
find $dirs -regex ".*\\.\\(cpp\\|hpp\\|c\\|h\\|ipp\\)" | xargs clang-format -style=file --Werror --dry-run -i

- name: doxygen
if: inputs.doxygen == true
working-directory: source-repo
shell: bash
run: |
set -ex
doxygen Doxyfile
set -ex
doxygen Doxyfile

# bazel format
- name: Install wget
Expand Down Expand Up @@ -127,14 +127,10 @@ runs:
run: |
echo \`\`\` >> format-report.txt

- uses: thollander/actions-comment-pull-request@v2
if: failure()
with:
filePath: format-report.txt
comment_tag: format
- uses: thollander/actions-comment-pull-request@v2
if: success() && github.event_name == 'pull_request'
with:
message: |
:white_check_mark: format check passed.
comment_tag: format
- name: Print format report
if: always()
shell: bash
run: |
echo "=== Format Report ==="
cat format-report.txt
echo "===================="
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ concurrency:

jobs:
run-bench:
runs-on: [atc-ubuntu-latest]
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: install deps
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/fuzz_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Fuzz PR

on:
pull_request:
merge_group:
workflow_dispatch:

concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
unix-fuzz:
strategy:
fail-fast: false
matrix:
flags:
[
"",
"-DACTIVE_STACK_OVERFLOW_CHECK=1 -DLINEAR_MEMORY_BOUNDS_CHECKS=1 -DACTIVE_DIV_CHECK=1",
]
runner:
- ubuntu-latest
- ${{ contains(github.repositoryUrl, 'bmw') && 'cawe-linux-arm64-compute-small' || 'ubuntu-24.04-arm' }}

runs-on: ${{ matrix.runner }}
container:
image: ubuntu:24.04
options: --user root
steps:
- name: Install Git
run: |
apt-get update -y -qq
apt-get install -y --no-install-recommends git ca-certificates
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/install-deps-x86_64
if: matrix.runner == 'ubuntu-latest'
- uses: ./.github/actions/install-deps-arm64
if: matrix.runner != 'ubuntu-latest'
- uses: ./.github/actions/fuzz-assets
with:
cmake_flags: -DCMAKE_BUILD_TYPE=Debug
cpp_flags: ${{ matrix.flags }}
- uses: ./.github/actions/fuzz-unix
with:
timeout: 900
cmake_flags: -DCMAKE_BUILD_TYPE=Debug
cpp_flags: ${{ matrix.flags }}

qemu-fuzz:
runs-on: ubuntu-latest
container:
image: ubuntu:24.04
options: --user root
steps:
- name: Install Git
run: |
apt-get update -y -qq
apt-get install -y --no-install-recommends git ca-certificates
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/install-deps-tricore
- uses: ./.github/actions/fuzz-qemu
with:
timeout: 900

all-green-fuzz:
runs-on: ubuntu-latest
if: always()

needs:
- unix-fuzz
- qemu-fuzz

steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
64 changes: 3 additions & 61 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Main
on:
pull_request:
merge_group:
workflow_dispatch:

concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
Expand Down Expand Up @@ -442,71 +443,14 @@ jobs:
set -ex
mkdir build
cd build
cmake .. -DVB_ENABLE_DEV_FEATURE=OFF -DENABLE_CLANG_TIDY=1 -DENABLE_WERROR=1 -DENABLE_SPECTEST=1 -DTEST_VARIANTS=1 -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DENABLE_UNITTEST=1 -DENABLE_DIS=1
cmake .. -DVB_ENABLE_DEV_FEATURE=OFF -DENABLE_CLANG_TIDY=1 -DENABLE_WERROR=1 -DENABLE_SPECTEST=1 -DTEST_VARIANTS=1 -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DENABLE_UNITTEST=1 -DENABLE_DIS=1
make -j $(sysctl -n hw.physicalcpu)
make test
rm -rf *
cmake .. -DVB_ENABLE_DEV_FEATURE=OFF -DENABLE_WERROR=1 -DENABLE_SPECTEST=1 -DTEST_VARIANTS=1 -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DENABLE_UNITTEST=1
cmake .. -DVB_ENABLE_DEV_FEATURE=OFF -DENABLE_WERROR=1 -DENABLE_SPECTEST=1 -DTEST_VARIANTS=1 -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DENABLE_UNITTEST=1
make -j $(sysctl -n hw.physicalcpu)
make test

unix-fuzz:
strategy:
fail-fast: false
matrix:
flags:
[
"",
"-DACTIVE_STACK_OVERFLOW_CHECK=1 -DLINEAR_MEMORY_BOUNDS_CHECKS=1 -DACTIVE_DIV_CHECK=1",
]
runner:
- ubuntu-latest
- ${{ contains(github.repositoryUrl, 'bmw') && 'cawe-linux-arm64-compute-small' || 'ubuntu-24.04-arm' }}

runs-on: ${{ matrix.runner }}
container:
image: ubuntu:24.04
options: --user root
steps:
- name: Install Git
run: |
apt-get update -y -qq
apt-get install -y --no-install-recommends git ca-certificates
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/install-deps-x86_64
if: matrix.runner == 'ubuntu-latest'
- uses: ./.github/actions/install-deps-arm64
if: matrix.runner != 'ubuntu-latest'
- uses: ./.github/actions/fuzz-assets
with:
cmake_flags: -DCMAKE_BUILD_TYPE=Debug
cpp_flags: ${{ matrix.flags }}
- uses: ./.github/actions/fuzz-unix
with:
timeout: 900
cmake_flags: -DCMAKE_BUILD_TYPE=Debug
cpp_flags: ${{ matrix.flags }}

qemu-fuzz:
runs-on: ubuntu-latest
container:
image: ubuntu:24.04
options: --user root
steps:
- name: Install Git
run: |
apt-get update -y -qq
apt-get install -y --no-install-recommends git ca-certificates
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/install-deps-tricore
- uses: ./.github/actions/fuzz-qemu
with:
timeout: 900

all-green:
runs-on: ubuntu-latest
if: always()
Expand All @@ -523,8 +467,6 @@ jobs:
- aarch64_windows_cmake_build
- x86-64_android_cmake_build_test
- aarch64_mac_cmake_build_test
- unix-fuzz
- qemu-fuzz

steps:
- name: Decide whether the needed jobs succeeded or failed
Expand Down
4 changes: 2 additions & 2 deletions binding/python/binding_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class RuntimeWrapper {
return readFromLinearMemory(static_cast<uint32_t>(offset.getValue()), size);
}
pybind11::bytes readFromLinearMemory(uint32_t const offset, uint32_t const size) const {
uint8_t *const ptr = runtime_.getLinearMemoryRegion(offset, size);
uint8_t const *const ptr = runtime_.getLinearMemoryRegion(offset, size);
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
return pybind11::bytes{reinterpret_cast<char const *>(ptr), size};
}
Expand Down Expand Up @@ -197,7 +197,7 @@ class RuntimeWrapper {

executeWasm([&func, &serArgs, &results, &ret, signature]() {
vb::SignalFunctionWrapper::call(func, vb::pCast<uint8_t const *>(serArgs.data()), vb::pCast<uint8_t *>(results.data()));
uint8_t *resultPtr = results.data();
uint8_t const *resultPtr = results.data();
std::string const resultsType = signature.substr(signature.find(")") + 1);
for (char const type : resultsType) {
switch (type) {
Expand Down
4 changes: 2 additions & 2 deletions demo/vb_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ static vb::Span<const uint8_t> loadWasmBytecode(std::string const &filePath) {
return vb::Span<const uint8_t>(bytecode.data(), bytecode.size());
}

static uint8_t *getStackTop() {
static uint8_t const *getStackTop() {
vb::MemUtils::StackInfo const stackInfo{vb::MemUtils::getStackInfo()};
uint8_t *const stackTop{vb::pCast<uint8_t *>(stackInfo.stackTop)};
uint8_t const *const stackTop{vb::pCast<uint8_t *>(stackInfo.stackTop)};
return stackTop;
}

Expand Down
9 changes: 4 additions & 5 deletions disassembler/disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ static_assert(false, "Backend not supported");

class CSDissembler final {
public:
CSDissembler(cs_arch arch, cs_mode mode, std::vector<uint32_t> const &instructionAddresses) noexcept : instructionAddresses_(instructionAddresses) {
err_ = cs_open(arch, mode, &handle_);
CSDissembler(cs_arch arch, cs_mode mode, std::vector<uint32_t> const &instructionAddresses) noexcept
: instructionAddresses_(instructionAddresses), handle_(0U), err_(cs_open(arch, mode, &handle_)) {
}

CSDissembler(CSDissembler &) = delete;
Expand Down Expand Up @@ -254,9 +254,9 @@ class CSDissembler final {
}

private:
csh handle_ = 0U;
cs_err err_;
std::vector<uint32_t> const &instructionAddresses_;
csh handle_;
cs_err err_;
};

static std::string trimtabs(const std::string &str) {
Expand Down Expand Up @@ -289,7 +289,6 @@ DisassemblerImpl::MultiStringOutput DisassemblerImpl::printMachineCode(uint8_t c
std::string second;
};
std::vector<InternalMultiStringOutput> outputBuffer;

uint16_t maxInstSize = 0;
for (const cs_insn &index : insn) {
InternalMultiStringOutput out;
Expand Down
2 changes: 1 addition & 1 deletion fuzz/afl_harness/persistent/persistentharness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int main(int argc, const char *argv[]) {
} else {
exit(0);
}
uint8_t *const buf = fuzz_buf.data();
uint8_t const *const buf = fuzz_buf.data();
ssize_t const len = static_cast<ssize_t>(fread(fuzz_buf.data(), 1, sizeof(fuzz_buf), snapshot));
#endif

Expand Down
3 changes: 1 addition & 2 deletions fuzz/fuzz_with_debugger/fuzz_with_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/


#include <chrono>
#include <cstddef>
#include <cstdio>
Expand Down Expand Up @@ -284,7 +283,7 @@ static void handleLine(char const *const lineStart, uint32_t const lineLength, u
std::vector<uint8_t> results(expectedReturnValues.size() * 8);
wasmModule.callRawExportedFunctionByName(functionName, stackTop, nullptr, results.data());

uint8_t *resultPtr = results.data();
uint8_t const *resultPtr = results.data();
for (ExpectedData const &expected : expectedReturnValues) {
std::string const expectedType = expected.type;
std::string const expectedValue = expected.value;
Expand Down
2 changes: 1 addition & 1 deletion fuzz/reference/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void fuzz() {

std::vector<uint8_t> results(expectedReturnValues.size() * 8);
wasmModule.callRawExportedFunctionByName(funcNameSpan, stackTop, nullptr, results.data());
uint8_t *resultPtr = results.data();
uint8_t const *resultPtr = results.data();

for (ExpectedData const &expected : expectedReturnValues) {
std::string const expectedType = expected.type;
Expand Down
Loading
Loading