added write_buf_sem race condition detector