2026-03-13 –, Tutorials 2 Language: English
OCaml has a reputation for keeping its promises: strong types, solid abstractions, and very few runtime surprises. Multicore parallelism changes the rules a bit: suddenly, we can encounter race conditions, the kind of bugs that only show up at 3 AM, disappear when you add a print statement, and return months later just to spite you. If we want to stay in OCaml’s comfort zone, we need good tools.
This talk takes a user’s tour through the current toolbox for multicore safety in OCaml. After a brief introduction to OCaml’s memory model, we explore the practical helpers available today, including a race detector (ThreadSanitizer), a model checker, and a property-based concurrency tester. These tools are similar, albeit less mature, to those found in other languages. However, we show that when combined, they already provide a surprisingly robust workflow for debugging multicore code without compromising your sanity.
Then we look at a more radical option: OxCaml, a promising but experimental mode-system extension inspired by Rust’s ownership model. The idea is simple: if you really dislike runtime bugs, or if you’re writing critical software, you shouldn’t just detect data races, you should make them statically impossible to write.
In brief, OCaml already provides the tools you need for everyday multicore safety, and OxCaml points toward an even more reassuring future for those who require the strongest guarantees.
A- For OCamlers: Combining existing tools for multicore safety
1- ThreadSanitizer + qcheck-stm: qcheck-stm generates randomized tests, making rare interleavings far more likely to occur during testing. Running these tests under ThreadSanitizer then reveals hidden data races with precise traces.
2- Qcheck-stm + dscheck: qcheck-stm can generate buggy tests that can then be explored with the model checker dscheck to find the exact buggy interleaving. This turns nondeterministic failures into deterministic, reproducible traces, making debugging race conditions dramatically easier.
B- For non-OCamlers:
The most essential tool is ThreadSanitizer, and every (non-data-race-free) language with multicore support benefits from it. However, TSan alone is not enough: it won't catch race conditions on atomics, for example.
C- For curious people: Learn how data-race freedom can be enforced statically, even in a language that wasn’t initially designed for it.
OxCaml demonstrates that by extending OCaml’s type system with modes, it becomes possible to ensure data race freedom statically. This shows that the idea of “Rust-like safety” isn’t exclusive to Rust: other languages can retrofit similar guarantees without redesigning the whole language.
I started out as a physicist, then got happily lost in functional programming with OCaml and resurfaced as a software engineer. When OCaml gained shared-memory parallelism, I discovered a new passion, and I’ve been diving deeper ever since.