Demo: Time of Check to Time of Use¶
A shop with a million items and eight buyers.
Read buy_one() in toctou.c before running anything.
Run¶
Ask¶
- Every access to
stockis under the lock. Isbuy_one()correct? - How can the shop sell more than it has? What happens between the check and the take?
- What does
check-and-actlock differently? - Would a race detector find this?