BoltsFramework / Bolts-ObjC

Bolts is a collection of low-level libraries designed to make developing mobile apps easier.
Other
5.64k stars 576 forks source link

Fix completed var thread safety problem #307

Closed Mourad-Aly closed 7 years ago

Mourad-Aly commented 7 years ago

Hi,

I've faced racing condition while using Bolts in our Apps, same issue reported before https://github.com/BoltsFramework/Bolts-ObjC/issues/302 Hot fix is to ensure locking the completed variable, however I don't know why wasn't it already in the lock block (deadlock?)? This is why I'm submitting this PR to ensure that the server tests will not fail since I'm unable to run tests locally (will figure this out). I'd suggest handling thread safety for BFTask in an easier-to-read way than locks, what do you think? GCD for example, sync_barrier?

Updates: I've just seen https://github.com/BoltsFramework/Bolts-ObjC/pull/303 👍

Mourad-Aly commented 7 years ago

Hi @nlutsenko, Seems a deadlock, since self.condition will wait in self.lock, and self.condition's signaling is happening in another self.lock block as well. I'm running tests locally to check whether it's caught by tests or not. Any concern is appreciated. Thanks.