LLVM’s Real-Time Safety Revolution
Tools for Modern Audio Development
"Error: RealtimeSanitizer: call to malloc
detected during execution of nonblocking function MyAudioCallback::process!"
"Warning (-Wfunction-effects): nonblocking function `MyAudioCallback::process` must not call blocking function `SketchyCall`"
Real-time programmers working on mission-critical audio, autonomous vehicle, and aerospace code are well-acquainted with the golden rule: “Thou shalt not call time-unbounded operations in your real-time thread.” Despite its importance, tools to enforce this rule have been non-existent—until now!
At ADC 2023, we presented RealtimeSanitizer; and now it's coming to mainline Clang. In the latest version of LLVM, RealtimeSanitizer (now RTSan) forms one of two new features that help uphold real-time guarantees by detecting calls to malloc, system calls, and other user-defined "unsafe" functions at runtime. We introduce the sanitizer, how it works, and how to use it. Next, we explore Clang's new Performance Constraints system, which can prevent blocking function calls from non-blocking functions at compile time. We will compare and contrast these methods and offer recommendations on how to integrate them into your codebase effectively.
By leveraging these new tools, you can ensure your real-time audio systems remain robust, reliable, and ready for any challenge.
David Trevelyan
Director
David Trevelyan Audio Limited
I've been developing software for 15 years in academia, start-ups, big tech, and as an independent consultant. I completed a PhD in computational physics at Imperial College London before becoming an early engineer at Jukedeck, taking the company to acquisition by TikTok in 2019. At TikTok I spent 4 years as technical lead and architect of the company's foundational real-time audio and music processing SDK. Here I also designed and led the development of a number of fun new musical experiences, including mawf - an interactive AI timbre-transfer plugin instrument, which can be downloaded for free at https://mawf.io.
More recently, I invented RealtimeSanitizer which (thanks to my talented co-authors) is now integrated into the LLVM project. Most of my work now is as an independent audio software engineering consultant. My experience covers the full audio stack; high-level audio systems and multi-threaded architecture, real-time neural network inference, virtual instrument and engine development, digital and virtual-analogue signal processing, SIMD optimisation, and developer tooling. If I can help on your project, please get in touch!
Chris Apple
Lead Audio Software Engineer
Chris Apple is a seasoned software engineer and team lead with nearly a decade of experience in the audio industry -- spanning everything from test automation in python, to loudspeaker installation in Tokyo nightclubs. Using his expertise in real-time audio rendering, he has made contributions to companies such as Dolby, Roblox, and Spatial Inc, as well as many open source projects. Recently, he has focused primarily on real-time safety and rendering performance in audio playback systems written in C++. This focus has led to his work on RealtimeSanitizer. This new sanitizer in the LLVM ecosystem provides runtime checks to ensure time-unbound operations cannot be called from real-time contexts.