Pattern-matching on mutable values: danger!
summary
The OCaml pattern-matching compiler produces incorrect code in a corner case: matching on a value with mutable fields that are mutated during pattern-matching — via when-clauses, allocation callbacks, or a concurrent access race — can flip which branch executes. The authors trace the compiler’s matching strategy, measure the failure modes, and propose weakening optimization metadata so generated code remains correct for mutable data; the fix also covers lazy patterns and multicore races.
AI-written summary · about
chapters (6)
- 0:00Introduction
- 1:09Speaker introduction
- 3:23Problem with pattern matching
- 12:00Unsafe pattern matching example
- 15:54Consequences and performance
- 20:07Q&A
related talks
29mPredicate Dispatch
08mCompiling pattern matching to in-place modifications
01h 00m“Using Compile-time Code Generation to build an LLVM IR Pattern Matcher”
39mPattern Matching: Small Enhancement or Major Feature?
52mPattern Matching: Small Enhancement or Major Feature?
29mThe Art of Java Language Pattern Matching
01h 26mImplementing Dependent Pattern Matching and Type Unification Part 2
51mSimple, Extensible Pattern Matching in C++14
