tidwall / SwiftWebSocket

Fast Websockets in Swift for iOS and OSX
MIT License
1.53k stars 244 forks source link

Fix non-thread-safe mutex access #141

Open IanHoar opened 5 years ago

IanHoar commented 5 years ago

When running SwiftWebSocket with the Thread Sanitizer, we noticed that there was a swift race condition when accessing the Manager's, or InnerWebSocket's mutex. Suspecting that this was simply a bug with the Thread Sanitizer we filed a Radar with Apple. Their response was this was actually a true positive and directed us to this article: http://www.russbishop.net/the-law.

Because Swifts & might allow for mutation on multiple threads, we need to allocate our own memory for the mutex to avoid a heap corruption.

bielikb commented 5 years ago

Will this fix make it to the release?

helje5 commented 5 years ago

Works fine for me, ran into the same issue.

iwasrobbed-ks commented 5 years ago

👍 confirmed this fixed an issue seen in the thread sanitizer