Skip to content

Use realtime sanitizer to check against malloc and similar#885

Draft
inkreasing wants to merge 2 commits into
RustAudio:masterfrom
inkreasing:rtsan_tests
Draft

Use realtime sanitizer to check against malloc and similar#885
inkreasing wants to merge 2 commits into
RustAudio:masterfrom
inkreasing:rtsan_tests

Conversation

@inkreasing
Copy link
Copy Markdown

@inkreasing inkreasing commented May 22, 2026

This adds tests that use the llvm realtime sanitizer. It checks known blocking libc calls. If you do a endless loop, it won't catch it.

I use the supertrait_item_shadowing thing to overwrite the Iterator::next method, so that it gets sanitized. This should be correct, as that is all audio code. That way it also applies to user written code. It leads to errors if both Source and Iterator are imported, but this is only for tests.

This is currently broken because

  1. doesn't work on nix (need help fixing this, i don't use nix)
  2. currently the library isn't realtime safe, so either this gets fixed or allows need to be applied (this should probably be done by running the sanitizer in continue mode, so that multiple issues can be found in one run)
  3. there should be more tests (i don't know whats useful, i just copied one example)

It could/should get extended by

  1. allowing users to easily test their own stuff
  2. maybe also test the examples with this

also still need to figure out if it is better to do it with the cargo feature (like it is currently) or use a env-var with a tiny build script. This has the big advantage, that user crates don't have to pass the feature upwards and can just set the env var.

@yara-blue

@roderickvd
Copy link
Copy Markdown
Member

This is cool. We’ve got ASAN and TSAN set up in cpal too. Using it as a pipe cleaner for realtime allocations is useful too.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants