in reply to debugging a race

Why do you believe it is a race condition (particularly since you're not using threads), rather than something else, such as an execution environment difference?