imported patch bugs/987829-smart-size-fix-thread-safety.patch