UNSYNCHRONIZED does NOT unlock the mutex
Summary: My colleague tuomaspelkonen discovered a weird UNSYNCHRONIZED issue a few weeks ago and we ever since stopped using it. Now I finally have some time to root cause it. It turns out UNSYNCHRONIZED unlock the mutex then lock the mutex again, because it copy constructs LockedPtr for overriding the name within the scope, and copy construct locks the mutex again. A one character fix here is to take a reference of LockedPtr instead of copy construct it. However since this is my first time look at the code here, please advise if this is horribly wrong or propose better fix. Also added a test to reproduce the issue without the fix as well as verify the fix. Reviewed By: yfeldblum Differential Revision: D2633028 fb-gh-sync-id: a9e8d39b08d4d1265979f8bdaae83619566d10a0
Showing
Please register or sign in to comment