Recording and replaying computer programs includes detecting whether a
race condition exists among multiple threads of a multithreaded
application program. In an embodiment, detecting race conditions
comprises detecting and preventing an operation of a first thread of an
application program to read or write a computer memory, wherein the
application program executes a plurality of threads; storing an exception
point representing a current location in an execution path of the
application program; allowing the operation to read or write the memory;
creating and storing a record identifying the memory, the first thread,
and an index value for a location in the execution path; and determining,
based on the record and a plurality of other similar records, whether a
race condition exists at the exception point for the first thread and one
or more other threads in the plurality of the threads.