Fixed deadlock due to gcc optimizations.