Lion Cipher Lab

Record and replay a bug backwards with rr: find who overwrote a value

Why it matters

The hardest bugs are the ones where the damage and the cause are far apart in time. A value is wrong when you print it, but whatever made it wrong ran a long time ago, in code you may not suspect. The usual tools force you to guess: add prints, run again, hope the bug happens again in the same way. A recorder removes the guessing. You capture the bad run once, then replay the same run as many times as you like, including backwards, and ask the question directly: who wrote this byte? Memory corruption, stack and heap overflows and use-after-free bugs are exactly this kind of bug, and the same…

What you'll learn

Steps in this lab

  1. The vocabulary, in plain words
  2. Can your machine run rr? Check before you spend an hour
  3. Write the buggy program and predict what it does
  4. Record the run, then replay it in gdb
  5. Ask the question: who wrote this value?
  6. Fix it and prove the fix
  7. Limits, when NOT to use rr, and how a pro does it better

Open the full interactive lab →

Keep learning