Grabbing mutex can cause deadlock