Skip to content

test/cmocka: hardcoded per-test -fsanitize flags break TSan/MSan builds and valgrind runs #159

Closed

Description

@zackees

Found while building the tree for the TSan and valgrind passes (round 2 meta issue linked as parent). This one is fork test infrastructure, not upstream code.

Problem

test/cmocka/CMakeLists.txt hardcodes sanitizer flags on individual tests:

  • test_avc: -fsanitize=undefined -fno-sanitize-recover=undefined
  • test_formatted_filename, test_utf8: -fsanitize=address,undefined -fno-sanitize-recover=undefined

Configuring the tree with any other sanitizer then breaks the build:

cc1: error: '-fsanitize=thread' is incompatible with '-fsanitize=address'
FAILED: test/cmocka/CMakeFiles/test_formatted_filename.dir/test_formatted_filename.c.o

These tests are in the default all target, so a plain cmake --build of a TSan (or MSan) configuration fails. Valgrind can't run the ASan-built binaries either. In the sanitizer harness they are built with -k 0 and skipped under TSan and valgrind.

Fix options

  1. Gate the per-test flags behind an option such as OBS_TEST_SANITIZE_PER_TARGET (default ON). Skip them when CMAKE_C_FLAGS already contains -fsanitize=.
  2. Or move to a project-wide ENABLE_SANITIZER=address|thread|undefined option and let these tests inherit it.

Per testing-policy.md this is a CMake change to test wiring, not to the C test sources, so the existing tests stay unchanged.

Activity

  1. added
    bug
    on Oct 10, 2026
  2. zackees commented on Oct 13, 2026

    @zackees
    MemberAuthor

    Claiming: #159. Plan (option 1): an obs_test_sanitize(<target> <sanitizers>) helper in test/cmocka that adds the per-test flags only when OBS_TEST_SANITIZE_PER_TARGET is ON (default) and the build isn't already sanitized. A ci/ check bans raw -fsanitize in the test wiring (RED), then every site moves to the helper (GREEN).

  3. added
    claimed
    on Oct 13, 2026
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

    bugclaimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions