Make a deep copy of the pthread attribute object to remove a potential use-after-free issue. (cherry picked from commit 42d35935)