sewenew / redis-plus-plus

Redis client written in C++
Apache License 2.0
1.64k stars 351 forks source link

async_sentinel.h: reorder fields to fix races in AsyncSentinel constructor #427

Closed andrzejc closed 1 year ago

andrzejc commented 1 year ago

While developing application using AsyncSentinel I discovered there are races in the constructor of AsyncSentinel which are caused by the order of fields intialization. The fields _mutex and _cv are used by the thread _worker however this thread is created before the fields are initialized. This was causing random crashes in my application. I fixed this by reordering the fields and now the crashes are gone.

sewenew commented 1 year ago

Thanks a lot for your contribution! That's a stupid bug, so sorry...

Regards