Fix broken FUTEX_LOCK_PI semantics.

Resolves #552.  Resolves #576.

@rocallahan if you don't mind, I could use another pair of eyes on the pseudo-proof that this approach is correct in the long comment in rec_process_event.cc.  (The rest of the patch is pretty straightforward.)