Skip to content

Would you consider adding static/dynamic analysis (clang-tidy, ASan, UBSan) to CI? #1276

@chenjjiaa

Description

@chenjjiaa

Hi LevelDB maintainers,

First, thank you for your work on this project! I noticed that the current CI pipeline (.github/workflows/build.yml) includes comprehensive builds and tests across platforms/compilers, but it doesn’t seem to include:

  1. Static analysis (e.g., clang-tidy, cppcheck)

    • Could help catch potential code quality issues early (e.g., style violations, misuse of APIs).
  2. Advanced dynamic checks (e.g., ASan, UBSan, TSan)

    • ASan (AddressSanitizer) for memory errors.
    • UBSan (UndefinedBehaviorSanitizer) for undefined behavior.
    • TSan (ThreadSanitizer) for data races (if multithreading is used).

Why this might be useful:

  • These tools are widely used in C++ projects (e.g., Chromium, LLVM) to catch subtle bugs.
  • They complement existing tests by focusing on security and stability issues that might not trigger test failures.
  • Sanitizers are especially valuable for a storage engine like LevelDB, where memory safety and data integrity are critical.

Example of potential additions:

# Static analysis with clang-tidy
- name: Run clang-tidy
  if: ${{ matrix.compiler == 'clang' }}
  run: |
    cmake -B "${{ env.CMAKE_BUILD_DIR }}" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
    run-clang-tidy -p "${{ env.CMAKE_BUILD_DIR }}"

# Dynamic analysis with sanitizers
env:
  SANITIZER_FLAGS: "-fsanitize=address,undefined -fno-omit-frame-pointer"
  CFLAGS: ${{ env.SANITIZER_FLAGS }}
  CXXFLAGS: ${{ env.SANITIZER_FLAGS }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions