# Can we get RealtimeSanitizer in Julia?

**URL:** https://discourse.julialang.org/t/can-we-get-realtimesanitizer-in-julia/119330
**Category:** General Usage
**Tags:** question
**Created:** [September 12, 2024, 2:36pm UTC](https://discourse.julialang.org/t/can-we-get-realtimesanitizer-in-julia/119330 "2024-09-12T14:36:33Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![GeorgeGkountouras](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@GeorgeGkountouras](https://discourse.julialang.org/u/GeorgeGkountouras)
#### Post date: [September 12, 2024, 2:36pm UTC](https://discourse.julialang.org/t/can-we-get-realtimesanitizer-in-julia/119330/1 "2024-09-12T14:36:33Z")

</div>

## Introduction

At last year’s Audio Developer Conference, [RealtimeSanitizer](https://github.com/realtime-sanitizer/rtsan), a tool for detecting function calls that are unsafe in a realtime context, [was presented](https://www.youtube.com/watch?v=P8rDWmmMmlg). RTSan is now being upstreamed to LLVM 20 and will be presented at cppcon this Monday.

## Motivation

Outside audio, [Julia is](https://www.youtube.com/watch?v=_--fIr5ConA) already [being used](https://www.youtube.com/watch?v=N1EfDWHlXLo) in some [realtime applications](https://www.youtube.com/watch?v=EafTuyy7apY). However, there are currently no runtime or compile-time checks to mark a function realtime-safe. Some related tooling (e.g. AllocCheck.jl) exists.

## Feasibility

Although implemented for C++, RTSan is designed with future use in other LLVM-based languages in mind. The language front-end only has to add a single attribute to the LLVM intermediate representation (IR), and activate the RealtimeSanitizer “optimization” where sanitization is desired. The authors have indicated that they are willing to help implement this in other languages, but cannot commit to the resulting maintenance.

---

<div class="post-metadata">

### Author: ![minetest2048](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/minetest2048/32/45961_2.png) [@minetest2048](https://discourse.julialang.org/u/minetest2048)
#### Post date: [September 13, 2024, 12:36am UTC](https://discourse.julialang.org/t/can-we-get-realtimesanitizer-in-julia/119330/2 "2024-09-13T00:36:59Z")

</div>

From the ADC conference and [RealtimeSanitizer — Clang 20.0.0git documentation](https://clang.llvm.org/docs/RealtimeSanitizer.html) RTSan works by intercepting call to C/C++ functions `malloc`, `pthread_mutex_lock` at runtime instead of compile time. I think the reason is that they want to detect realtime violations in closed-source precompiled library: [https://youtu.be/P8rDWmmMmlg?si=HyL5VPZbcUFE2uUz&t=1161](https://youtu.be/P8rDWmmMmlg?si=HyL5VPZbcUFE2uUz&t=1161)

In Julia we can do better, as we have access to LLVM IR of most(?) of the functions, so we can analyze it and detect call to realtime-unsafe functions at compile time. This is how AllocCheck.jl works. We can even detect inlined system calls.

My feeling is that AllocCheck.jl is our RTSan, we need to blacklist more functions in [AllocCheck.jl/src/classify.jl at main · JuliaLang/AllocCheck.jl · GitHub](https://github.com/JuliaLang/AllocCheck.jl/blob/main/src/classify.jl) . For example [AllocCheck.jl/src/classify.jl at 481adc452f966a8f13c4f12e1607b33654fcbee8 · JuliaLang/AllocCheck.jl · GitHub](https://github.com/JuliaLang/AllocCheck.jl/blob/481adc452f966a8f13c4f12e1607b33654fcbee8/src/classify.jl#L67) says that `gc_collect` is a ‘safe’ non-allocating function, which might be true, but garbage collection is definitely not realtime safe

---

<div class="post-metadata">

### Author: ![GeorgeGkountouras](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@GeorgeGkountouras](https://discourse.julialang.org/u/GeorgeGkountouras)
#### Post date: [September 13, 2024, 1:32pm UTC](https://discourse.julialang.org/t/can-we-get-realtimesanitizer-in-julia/119330/3 "2024-09-13T13:32:16Z")

</div>

Yes, RTSan works for opaque binaries created with C/C++ (or any other “extern C” languages). Since Julia is a general-purpose language, this is a supported workflow.

Therefore, I don’t see RTSan as a replacement for AllocCheck.jl, but rather complementary functionality.

---

<div class="post-metadata">

### Author: ![GeorgeGkountouras](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@GeorgeGkountouras](https://discourse.julialang.org/u/GeorgeGkountouras)
#### Post date: [October 21, 2024, 6:56pm UTC](https://discourse.julialang.org/t/can-we-get-realtimesanitizer-in-julia/119330/4 "2024-10-21T18:56:40Z")

</div>

[![](https://global.discourse-cdn.com/julialang/original/3X/3/1/31348938234052771ea8b8c0f902abc20c6824d0.jpeg "Catching Real-time Safety Violations in C++ - Dave Rowland - C++ on Sea 2024") ](https://www.youtube.com/watch?v=n_jeX1s1rkg)

---

<div class="post-metadata">

### Author: ![GeorgeGkountouras](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@GeorgeGkountouras](https://discourse.julialang.org/u/GeorgeGkountouras)
#### Post date: [November 22, 2024, 5:04pm UTC](https://discourse.julialang.org/t/can-we-get-realtimesanitizer-in-julia/119330/5 "2024-11-22T17:04:54Z")

</div>

Update from this year’s ADC presentation: in addition to the runtime checks, Clang now has complementary compile-time checks that work with function annotations:

 ![nonblocking](https://global.discourse-cdn.com/julialang/original/3X/6/8/6859765221e9ababca149afe3ca4a138300495a4.jpeg)  
 ![nonallocating](https://global.discourse-cdn.com/julialang/original/3X/6/3/63da30280082faf85c295cc60f622b60520e5432.jpeg)

---

<div class="post-metadata">

### Author: ![GeorgeGkountouras](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@GeorgeGkountouras](https://discourse.julialang.org/u/GeorgeGkountouras)
#### Post date: [December 9, 2024, 3:14pm UTC](https://discourse.julialang.org/t/can-we-get-realtimesanitizer-in-julia/119330/6 "2024-12-09T15:14:39Z")

</div>

I’d like to stress once again that the LLVM tooling is **not** only for runtime checks. A comparison between the 2 methods:

 ![comparison1](https://global.discourse-cdn.com/julialang/original/3X/7/a/7abf7cf1d50bf8e738ceedd6b33b152e319536f8.png)  
 ![comparison2](https://global.discourse-cdn.com/julialang/original/3X/b/8/b8b3ec4676cee138e04c8b81fd4893d42d148fc4.png)

---

<div class="post-metadata">

### Author: ![GeorgeGkountouras](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@GeorgeGkountouras](https://discourse.julialang.org/u/GeorgeGkountouras)
#### Post date: [December 18, 2024, 1:49pm UTC](https://discourse.julialang.org/t/can-we-get-realtimesanitizer-in-julia/119330/7 "2024-12-18T13:49:46Z")

</div>

[![](https://global.discourse-cdn.com/julialang/original/3X/2/a/2a8ff0ec49b6194d6f9930de9926aed2f14276a6.jpeg "LLVM's Realtime Safety Revolution: Tools for Modern Mission Critical Systems - CppCon 2024") ](https://www.youtube.com/watch?v=KvhgNdxX6Uw)

---

<div class="post-metadata">

### Author: ![GeorgeGkountouras](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@GeorgeGkountouras](https://discourse.julialang.org/u/GeorgeGkountouras)
#### Post date: [January 21, 2025, 2:07pm UTC](https://discourse.julialang.org/t/can-we-get-realtimesanitizer-in-julia/119330/8 "2025-01-21T14:07:42Z")

</div>

RealtimeSanitizer is now available for Rust!

[https://steck.tech/posts/rtsan-in-rust/](https://steck.tech/posts/rtsan-in-rust/)

[https://github.com/realtime-sanitizer/rtsan-standalone-rs/](https://github.com/realtime-sanitizer/rtsan-standalone-rs/)

---

<div class="post-metadata">

### Author: ![GeorgeGkountouras](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@GeorgeGkountouras](https://discourse.julialang.org/u/GeorgeGkountouras)
#### Post date: [March 28, 2025, 3:25pm UTC](https://discourse.julialang.org/t/can-we-get-realtimesanitizer-in-julia/119330/9 "2025-03-28T15:25:04Z")

</div>

RTSan is now also available for Swift!

[https://infinum.com/blog/realtimesanitizer-swift/](https://infinum.com/blog/realtimesanitizer-swift/)

[https://github.com/realtime-sanitizer/RTSanStandaloneSwift](https://github.com/realtime-sanitizer/RTSanStandaloneSwift)

---

<div class="post-metadata">

### Author: ![GeorgeGkountouras](https://avatars.discourse-cdn.com/v4/letter/g/77aa72/32.png) [@GeorgeGkountouras](https://discourse.julialang.org/u/GeorgeGkountouras)
#### Post date: [November 9, 2025, 8:10pm UTC](https://discourse.julialang.org/t/can-we-get-realtimesanitizer-in-julia/119330/10 "2025-11-09T20:10:04Z")

</div>

LLVM Realtime Sanitizer merged into the Rust compiler

[https://github.com/rust-lang/rust/pull/147935](https://github.com/rust-lang/rust/pull/147935)
