lcb_next_rand64 is not thread safe
Description
Environment
None
Gerrit Reviews
None
Release Notes Description
None
Activity
Show:
CB robot August 6, 2018 at 10:14 PM
Build couchbase-server-6.5.0-1167 contains libcouchbase commit 8d7babf with commit message:
: Random seed generater does not need to be alive as static thread_local
CB robot August 6, 2018 at 9:34 PM
Build libcouchbase-2.8.5-224 contains libcouchbase commit 8d7babf with commit message:
: Random seed generater does not need to be alive as static thread_local
Brian Hong July 31, 2018 at 4:52 AM
Looks good to me
CB robot July 30, 2018 at 6:10 PM
Build libcouchbase-2.8.5-221 contains libcouchbase commit 3d610ad with commit message:
: Declare random generator as thread local
CB robot July 30, 2018 at 4:58 PM
Build couchbase-server-6.5.0-1136 contains libcouchbase commit 3d610ad with commit message:
: Declare random generator as thread local
Fixed
Pinned fields
Click on the next to a field label to start pinning.
Created July 30, 2018 at 7:31 AM
Updated April 24, 2020 at 11:46 PM
Resolved August 21, 2018 at 6:25 PM
Instabug
We ran ThreadSanitizer on a binary using libcouchbase, and we get constant warnings about data race in libcouchbase[1]
According to the manual[2] using different lcb_t data structure between different threads should be thread-safe. But the lcb_next_rand64 function[3] defines static variables, so this doesn't hold.
[1]: ThreadSanitizer warning
[2]: http://docs.couchbase.com/sdk-api/couchbase-c-client-2.8.3/lcb_thrsafe.html
[3]: https://github.com/couchbase/libcouchbase/blob/master/src/rnd.cc