Skip to content

Fix fuzzing workflow: ASAN sanitizer incompatible with musl target #45

@RAprogramm

Description

@RAprogramm

Fix fuzzing workflow failure caused by ASAN sanitizer incompatibility with musl target.

Problem

Fuzzing workflow fails with error:

error: sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static`

error[E0463]: can't find crate for `std`
  = note: the `x86_64-unknown-linux-musl` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-linux-musl`

Root cause: cargo-fuzz automatically selects x86_64-unknown-linux-musl target which uses static libc linking, incompatible with ASAN sanitizer (-Zsanitizer=address).

Failed run: https://github.com/RAprogramm/cstring-array/actions/runs/18640282197

Solution

Use x86_64-unknown-linux-gnu target instead of musl:

  1. Add target installation step
  2. Set CARGO_BUILD_TARGET environment variable
  3. Or use --target flag in cargo-fuzz command

Implementation

Add to workflow before fuzzing step:

- name: Add gnu target
  run: rustup target add x86_64-unknown-linux-gnu

- name: Run fuzzer
  run: cargo fuzz run ${{ matrix.target }} --target x86_64-unknown-linux-gnu -- -max_total_time=300

Benefits

  • Fuzzing works with ASAN sanitizer
  • Better memory safety testing
  • CI passes successfully

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions