Dangerous Optimizations! in C++ - Part Deux
summary
Shows concrete compiler behaviors that break causality: a loop-invariant remainder hoisting undefined behavior on MSVC moves a division fault earlier, GCC O0 vs O2 reproduces the shifted crash, and integer promotions lead to integer promotion overflow that lets the optimizer remove a negative-branch. Demonstrates a Linux kernel exploit where null-deref plus mmap(0) executes attacker code and explains the fix (move the dereference or build with fno-delete-null-pointer-checks). Slides and examples live on the provided GitHub.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:24Dangerous optimizations premise
- 3:08Time travel UB in compilers
- 12:23C committee on UB
- 23:45UB types defined
- 26:14Compiler UB optimizations
- 31:55Integer overflow pitfalls
- 43:02Strict aliasing impact
- 52:07Effective type violations
- 1:01:47Null pointer risks
- 1:13:17Linux kernel exploit
- 1:22:39Best practices
related talks
01h 30mDangerous Optimizations in C and C++ Programming Languages
19mExploiting Undefined Behavior in C/C++ Programs for Optimization: A Study on the(…)
33mUndefined Behavior in C++: What Every Programmer Should Know and Fear
01h 04mCompiler Bugs And Bug Compilers
52mNon-conforming C++: the Secrets the Committee Is Hiding From You
15mC++ WAT
15mNot So Fast: Understanding and Mitigating Negative Impacts of Compiler Optimizations on Code Reuse G
57mC++ MythBusters Strike 2
