ThreadSanitizer gives false positive warning about deadlock

Please see details in https://gist.github.com/spetrunia/77274cf2d5848e0a7e090d622695ed4e.