Skip to content

Enable /fsanitize=address for the MSVC fuzz build #64

Description

@thomthom

Split out of #54.

With MSVC, FASTGPX_BUILD_FUZZERS=ON builds the fuzz targets against the standalone replay driver with no instrumentation at all. The else() branch in the top-level CMakeLists.txt only prints a notice. Since 4a1d0cf the corpus replays run on the Windows leg of cpp-tests.yml, so MSVC ASan would turn that leg into a sanitized run of the seed corpora and the Catch2 tests.

What MSVC offers

  • /fsanitize=address (VS 2019 16.9+). AddressSanitizer only; there is no UBSan for MSVC.
  • Incompatible with /RTC1 (Debug default), /INCREMENTAL and edit-and-continue. Release with /Zi works.
  • The dynamic ASan runtime DLL must be on PATH for /MD builds. VS 2022 17.7+ copies it next to the executable for local runs; the CI runner has it via the VS install.
  • Fixed by design: -fno-sanitize-recover has no equivalent, but ASan reports are fatal on MSVC anyway.

Proposal

In the else() branch, when MSVC is set:

add_compile_options(/fsanitize=address /Zi)
add_link_options(/INCREMENTAL:NO)

plus stripping /RTC1 from CMAKE_CXX_FLAGS_DEBUG the way NDEBUG is stripped already. Verify locally with build-fuzz-msvc (ctest -R ^fuzz_) and on the Windows job of cpp-tests.yml. Note that on this ARM64 dev machine the x64 MSVC binaries run emulated, so time the corpus replay before and after.

Also worth checking: whether clang-cl (CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") is worth a branch of its own, since it does have libFuzzer and UBSan on Windows.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfuzzerFound by or related to the fuzz targets in src/cpp/fuzz

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions