Skip to content

Clang RealtimeSanitizer support #76

Open
@messmerd

Description

@messmerd

The discussion in free-audio/clap#448 gave me the idea of marking real-time functions with a macro, say CLAP_REALTIME, rather than marking them as real-time in a comment.

By default, CLAP_REALTIME would be empty and do nothing (besides being documentation), but when compiled with Clang's new RealtimeSanitizer enabled in C or C++, it could provide runtime checking of CLAP API functions marked as real-time:

#if defined(__has_feature) && __has_feature(realtime_sanitizer)
#   define CLAP_REALTIME [[clang::nonblocking]]
#else
#   define CLAP_REALTIME
#endif

At least that's what I hoped we could do, but unfortunately it appears unlikely that [[clang::nonblocking]] can be applied to function pointers like those the CLAP API uses, though I haven't confirmed this yet. I was wrong, it actually is possible to use on function pointers.

Fortunately it should be possible to apply the RealtimeSanitizer here since this library uses regular functions instead of function pointers. clap-helpers is probably more fitting for this sort of thing anyway given the focus on enforcing correctness through the use of checking levels and misbehavior handlers. Putting them in the CLAP API will allow C23 programs to benefit from RtSan too.

Does this sound like a good idea?

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