Fixed a small bug when generating a counter for an atomic block.